Skip to content

Instantly share code, notes, and snippets.

@vitalyrotari
Forked from somebox/nginx.conf
Created May 15, 2014 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitalyrotari/bd94c2277c930c5dd6e2 to your computer and use it in GitHub Desktop.
Save vitalyrotari/bd94c2277c930c5dd6e2 to your computer and use it in GitHub Desktop.
# The following recipe works with upstream rails proxy for custom 404s and 500s.
# Errors are usually handled via rails except if proxy is really down, in which case
# nginx needs a bit more configration.
server {
# ...
location / {
error_page 404 = @rails; # let rails show a page with suggestions
try_files maintenance.html @rails;
}
location @rails {
proxy_pass ...
proxy_intercept_errors on; # Important!
}
error_page 500 502 503 @error_page;
# this handles 50x errors that happen via upstream proxy,
# when the normal error_page directive alone is not enough.
location @error_page {
root /var/nginx/app/htdocs; # location of 500.html file
internal;
rewrite ^ /500.html;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment