Created
November 13, 2009 00:01
-
-
Save dstrelau/233446 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
error_page 503 @503; | |
location = /503.html { } | |
location = /down_for_maintenance.html { } | |
location @503 { | |
# If we are in maintenance mode and returning a 503, | |
# show the special maintenance page | |
if ( -f $document_root/SHOW_MAINTENANCE_PAGE ) { | |
rewrite ^.*$ /down_for_maintenance.html; | |
} | |
# But if a backend has just returned a 503 | |
# because it's overloaded, show the 503 page | |
if ( !-f $document_root/SHOW_MAINTENANCE_PAGE ) { | |
rewrite ^.*$ /503.html; | |
} | |
} | |
location / { | |
# Check if the requested file is on the filesystem | |
if (!-f $request_filename) { | |
set $not_found 1; | |
} | |
# If SHOW_MAINTENANCE_PAGE exists in webroot, | |
# we probably want to return a 503 maintenance page | |
if (-f $document_root/SHOW_MAINTENANCE_PAGE) { | |
set $maintenance 1; | |
} | |
# But if it's a static asset, we should skip | |
# the 503, provided the file exists | |
if ($request_filename ~* (css|jpg|png|gif)$) { | |
set $maintenance $not_found; | |
} | |
if ($maintenance) { | |
return 503; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment