Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Last active January 16, 2018 04:17
Show Gist options
  • Save StevenJL/60f3174ad824c4c9e2582f7f0d6d47f6 to your computer and use it in GitHub Desktop.
Save StevenJL/60f3174ad824c4c9e2582f7f0d6d47f6 to your computer and use it in GitHub Desktop.
# If there the upstream server errors, we want to with an error page.
# Note the `location` directive here is performing a regex match.
location ~* (script1|script2|script3)\.php$ {
proxy_pass http://192.168.0.1;
# The `error_page` directive will return the document file
# 50x.html depending on the upstream error.
error_page 500 502 503 504 /50x.html;
}
# Sometimes if the upstream server returns an error we want to
# go to a retry location.
location ~* (script4|script5|script6)\.php$ {
proxy_pass http://upstream;
error_page 500 502 503 504 403 404 @retry;
}
# The retry location tries a different upstream and if that still
# errors, it returns an error page.
location @retry {
proxy_pass http://upstream_backup;
error_page 500 502 503 504 = 200 /50x.html;
}
# vi: ft=nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment