How to debug nginx reverse proxy?
<p>In my use case, I am trying to do a reverse proxy using nginx server. I have two applications running in two ports. For example <code>app</code> server is running port <code>9090</code> and <code>api</code> server is running in <code>8081</code>.</p>

<p>I will be running nginx server in port in <code>8080</code>. If I get <code>/api</code> request, nginx should redirect to api server. Other requests should go to <code>app</code> server.</p>

<p>I have the following nginx.conf,</p>

<pre><code>worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    upstream app {
      server 127.0.0.1:9090;
      keepalive 64;
    }

    upstream api {
      server 127.0.0.1:8081;
      keepalive 64;
    }
    #
    # The default server
    #
    server {
      listen   8080;
      server_name  howti;

      location /api {
        rewrite /api/(.*) /$1  break;
        proxy_pass http://api;
        proxy_redirect off;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host   $http_host;
        proxy_set_header   X-NginX-Proxy true;
        real_ip_header     X-Forwarded-For;
            real_ip_recursive  on;
        #proxy_set_header   Connection "";
        #proxy_http_version 1.1;
      }

      location /{
        rewrite /(.*) /$1  break;
        proxy_pass http://app;
        proxy_redirect off;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host   $http_host;
        proxy_set_header   X-NginX-Proxy true;
        real_ip_header     X-Forwarded-For;
            real_ip_recursive  on;
        #proxy_set_header   Connection "";
        #proxy_http_version 1.1;
      }

        # redirect not found pages to the static page /404.html
        error_page  404  /404.html;
        location = /404.html {
            root   /usr/share/nginx/html;
        }

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
}
</code></pre>

<p>But it is not working. I am not able to debug the request in nginx? Could someone help me with this? Thanks</p>