Nginx and site maintenance


#1

I want to do some maintenance to a VPS site running under nginx. Assuming that

  • my IP address will be 1.2.3.4
  • I have created/placed the file /error503.html

Will the following additions to my nginx file block all users but me?

if ($remote_addr != "1.2.3.4") {
    return 503;
}

error_page 503 @maintenance;

location @maintenance {
    rewrite ^(.*)$ /error503.html break;
}

Thanks


#2

I’m not sure of the syntax for nginx, but I use something almost exactly the same in PHP and it does exactly what you want it to do.