Created
September 24, 2012 22:27
-
-
Save perusio/3778833 to your computer and use it in GitHub Desktop.
How to distinguish a real 503 from Drupal maintenance page in Nginx
This file contains 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
## This relies on using Lua. In particular the header_filter_by_lua. The solution is based | |
## on the presence of the Etag header for the drupal maintenance page (theme). For a real 503 | |
## there's no Etag. We set the header X-Maintenance to YES in that case. Now you can distinguish | |
## between a real 503 and the Drupal maintenance page. | |
error_page 503 = @503; | |
location @503 { | |
header_filter_by_lua ' | |
if ngx.header.etag ~= "" then | |
ngx.header.X_Maintenance = "YES" | |
end'; | |
return 503 "Site under maintenance. Well be back sthortly."; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment