To debug issues, or simply to have enough information at hand when investigating issues in the future, you can maximize the information about what is going on in your location
that uses proxy_pass
.
We found this handy log_format
, which I enhanced with a custom variable $upstream, as we have defined above. If you always call your variables $upstream in all your locations that use proxy_pass
, you can use this log_format
and have often much needed information in your log:
log_format upstream_logging ‘[$time_local] $remote_addr – $remote_user – $server_name to: $upstream: $request upstream_response_time $upstream_response_time msec $msec request_time $request_time’;
Here full example:
daemon off; events { } http { log_format upstream_logging '[$time_local] $remote_addr - $remote_user - $server_name to: "$upstream": "$request" upstream_response_time $upstream_response_time msec $msec request_time $request_time'; server { listen 8080; location /mywebapp/ { access_log /dev/stdout upstream_logging; set $upstream http://127.0.0.1:5000/api/; proxy_pass $upstream; } } }
However, we have not found a way to log the actual URI that is forwarded to $upstream, which would be one of the most important things to know when debugging proxy_pass
issues.
Similar Posts:
- how to secure nginx http traffic to upstream servers
- how to setup FusionAuth server with nginx and ssl
- nginx configuration for wordpress
- php 7.4 + nginx quick start on Windows 10 / Server 2012 / 2016 / 2019
- how to use VestaCP with Node.JS support.