Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
nginx maintenance mode
server {
listen 80;
root /var/www/;
location / {
if (-f $document_root/maintenance.html) {
return 503;
... # the rest of your config goes here
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;

This comment has been minimized.

Copy link
Owner Author

@rictorres rictorres commented Sep 11, 2015

Now whenever you need to take your site offline, simply create the file maintenance.html in the $document_root (in our case, /var/www/ If the file exists, Nginx will serve it with a 503 status code, if not, it will proceed as usual.

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