1

As I prepare to test some changes, I thought I'd set up a maintenance page block so I could do the testing.

Just realized though that the maintenance block examples for nginx take the site down for everyone.

How do you serve the maintenance page to visitors will still allowing localhost access.

Should I just create a new server block listening on another port and deny all, allow 127.0.0.1?

2 Answers 2

1

The way I do it is I have two copies of my site, one which is live and one which is development. I do a svn checkout to my development which and test it on there, and when changes are tested and ready I rsync them into my live environment.

Having a maintenance page because you're making changes really shouldn't be necessary unless you're making changes to for example a database where queries take several minutes to run.

But to answer your actual question, location blocks doesn't care about who is requesting the page, only about the URI. One work around would be to use the access module to deny access to anyone not you and then define the error page to be a maintenance page.

1
  • Sorry for the late thanks! Just looking over my account and realized I never responded.
    – Ian
    Apr 26, 2011 at 2:55
0

Instead of using the access module (like Martin Fjordvald suggested) which results in a 403 Forbidden error you should consider returning a 503 Service Temoporarily Unavailable with a custom error page:

server {
    # ... usual configuration here ...

    error_page  503 @maintenance;

    # Use this line if page is currently in maintenance mode
    return 503;

    location @maintenance {
        rewrite ^   /maintenance.html break;
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .