Skip to content

Instantly share code, notes, and snippets.

@dungdt88
Created September 29, 2017 09:46
Show Gist options
  • Save dungdt88/b75035b9b047a0dd8e19d26813a95cdf to your computer and use it in GitHub Desktop.
Save dungdt88/b75035b9b047a0dd8e19d26813a95cdf to your computer and use it in GitHub Desktop.
Nginx - Handle Response when Proxy is down

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";
  }

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment