How can I make Nginx return HTTP 503 when my proxied app server is down?
You can do so by setting an error page.
error_page 502 =503 /maintenance.html
With just the contents of Martin Fjordvald's answer I was still getting 502, I didn't have a real maintenance.html page, but this seems to work:
location / {
error_page 502 =503 /maintenance.html;
include proxy_params;
proxy_pass http://unix:/var/run/my.sock;
}
location /maintenance.html {
return 503;
}