Skip to content

Instantly share code, notes, and snippets.

@bcurren
Created December 21, 2010 19:19
Show Gist options
  • Save bcurren/750407 to your computer and use it in GitHub Desktop.
Save bcurren/750407 to your computer and use it in GitHub Desktop.
server {
location / {
if (-f $document_root/system/maintenance.html) {
return 503;
}
try_files $uri $uri/index.html @proxy;
}
error_page 503 @503;
location @503 {
# Serve static assets if found when in maintenance mode.
if (-f $request_filename) {
break;
}
# Serve the maintenance page if we're in maintenance mode.
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
}
# This is a normal 503 so serve that page.
rewrite ^(.*)$ /503.html break;
}
}
@kbeezie
Copy link

kbeezie commented Dec 21, 2010

$document_root is empty if there's no root in the server { } level.

  • kblessinggr from #nginx/freenode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment