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


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.

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

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;

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.