Present sorry page for everyone except you

Reading Time: 1 minute

 

During applications back-end systems maintenance operations, we usually present the so called sorry page to end users. This is a nice way to inform that something is going on, in particular on small systems not having a multi node configuration setup.

Typical pages are the one saying “I am sorry, the system is under maintenance, will be back soon”.

I usually configure the sorry page at reverse proxy level (nginx) since the backend system is most of the time going up and down.

The way I use is the following:

  • Create the HTML of the sorry page and I put in a local file system local /var/whatYouPrefer/www/sorry_page/index.html
  • Comment out the proxypass directive
  • Define a new document root for the website pointing to the sorry page’s location
                             root /var/whatYouPrefer/www/sorry_page/;
At this point, everyone will get the sorry page in place of a proxy service error.
This is fine, basic and easy. Everyone knows it. What about your access? What about you cannot access the HTTP service on the application server due to a local firewall configuration (in particular if you perform SSL termination you shouldn’t allow connections from players different than your reverse proxy) or due to a named based virtual hosting limitation.
The best way would be to create a conditional rule to provide the sorry page to everyone except than your IP address.
The way I usually go to achieve this result  is:

 

if ( $remote_addr ~* yourIPAddress) {
      proxy_pass http://remoteServer;
}
root /var/whatYouPrefer/www/sorry_page/;
The result of this is obvious, if your IP matches the one in the if condition, Nginx will proxy the backend service to you. If it doesn’t, NGINX will serve the sorry page.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.