When the proxied service is unavailable, Nginx will by default return HTTP code 502. We can change this response by the following config:
server {
location {
proxy_pass http://somehost/someuri
}
...
error_page 502 503 504 =503 @serviceunavailable;
location @serviceunavailable {
return 503 "Service is unavailable";
}
...