1. Download the maintenance_page.html

Start by downloading the maintenance_page.html from your Sorry™ account, and placing it into the Nginx document root.

The document root varies between configurations, but you'll usually find 5xx.html and 4xx.html files in there already.

2. Update your Nginx configuration

Make some changes to the Nginx configuration to detect and trigger the maintenance mode, here are the important bits to add:

server {
    location / {
        if (-f $document_root/maintenance.on) {
            return 503;

        ... Your normal location config here.

    error_page 503 @maintenance_page;

    location @maintenance_page {
        rewrite ^(.*)$ /maintenance_page.html break;

At the beginning of every request Nginx will now check for a file named "maintenance.on" in the document root. 

This allows you to toggle maintenance on/off by creating or removing that file, no need to restart the server or update the config each time.

If the "maintenance.on" file exists Nginx will return an HTTP 503 Service Unavailable error, which is recommended during temporary outages.

Nginx will then handle the 503 error, by serving up the maintenance_page.html which you downloaded from us earlier.

3. Restart, test and deploy

Once you've updated the configuration, you'll need to restart Nginx so it picks up the changes.

You can now test your setup by creating "maintenance.on" in the document root, and seeing the maintenance page served instead of the usual website.

Naturally, you'l want to test the setup comprehensively somewhere before you deploy it to production.

If you have any questions about your specific Nginx config then please don't hesitate to ask, I'll do my best to help.

Did this answer your question?