Welcome! Log In Create A New Profile

Advanced

Rewrite 502 upstream status

Posted by systrex 
Rewrite 502 upstream status
January 30, 2022 09:19AM
Hello All,

I have a use case where all of our upstreams become marked as down (servers shutdown etc)... This results in NGINX returning a 502 for the $upstream_status which is expected

$upstream_status
keeps status code of the response obtained from the upstream server. Status codes of several responses are separated by commas and colons like addresses in the $upstream_addr variable. If a server cannot be selected, the variable keeps the 502 (Bad Gateway) status code.

this also then returns a 502 for the variable $status...

$status
response status (1.3.2, 1.2.2)

where my issue comes is that its not easy to tell in troubleshooting if the 502 came from the above reason OR if the upstream server actually did send a 502 (instead of nginx generating it due to servers being marked as down)

is anyone aware of a way to overwrite this upstream_status and log a different status? capture said scenario and write out another var to the logs only for these requests etc? or any other solution that resovles this?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready