The original post: /r/nginx by /u/Kaleodis on 2024-08-08 21:12:41.

Hi everyone, I hope someone could help me with a small snippet.

I currently have nginx set up as a reverse proxy for a bunch of services - which sometimes go down. When these are down, nginx displays a generic 502 error page.

I would like to redirect the user to a custom status page (hosted at status.mydomain.tld) if the service is down (and thus would generate a 502). I have found the error_page directive (and the @ location thingy), although I’m unsure on how to use it.

I currently have a file for every subdomain (with a server {} block in it for port 443 (and 80 redirecting to it)) and would like to not repeat too much - if possible i’d like to set the redirect stuff exactly once.

Anyone has any experience doing this?