I spent some time recently pounding my head against a wall while trying to configure an NGINX proxy. What helped me solve the issue was setting up some custom logging.
Inside the HTTP section, you can specify a log_format. The log_format defines what will go into the log file and there are a lot of variables available.
2'"proxy_host" $proxy_host'
3'"proxy_add_x_forwarded_for" $proxy_add_x_forwarded_for'
4'"upstream_addr" $upstream_addr'
5'"proxy_protocol_addr" $proxy_protocol_addr'
6'"proxy_protocol_server_addr" $proxy_protocol_server_addr'
7'"request_uri" $request_uri'
8'"request" $request'
9'"http_x_forwarded_for" $http_x_forwarded_for'
10'"status" $status'
11'"args" $args';
A key thing to notice is that right after the log_format I gave the logging a name "devlogging". You can name it anything you want.
After that, you tell nginx to use this:
Now, watch the console and you'll see output as you hit your proxy URLs:
2"proxy_host": redacted-server
3"proxy_add_x_forwarded_for": 172.17.0.1
4"upstream_addr": redacted
5"proxy_protocol_addr": -
6"proxy_protocol_server_addr": -
7"request_uri": /redacted?arglist=redacted
8"request": GET /redacted?arglist=redacted HTTP/2.0
9"http_x_forwarded_for": -
10"status": 200
11"args": arglist=redacted
This info gave me insight into the request I was making and it helped me figure out what I was doing wrong. However, for some foolish reason, you can get a lot of info about the request in NGINX, but not the forward after the re-write rules to see the final forwarded destination. I was greatly dismayed because this re-write info was extremely useful when I was debugging rewrite rules for the Angular development server.