Skip to content

Instantly share code, notes, and snippets.

@perusio
Created September 24, 2012 22:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perusio/3778833 to your computer and use it in GitHub Desktop.
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 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