A better "site not available" page

I’m running such a setup on two instances. Actually, it was quite easy:

My outer nginx is configured as described here, and then I simply added an error_page directive and a location for the error page itself:

        location / {
                error_page 502 =502 /errorpages/discourse_offline.html;
                proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
        }

        location /errorpages/ {
                alias /var/www/errorpages/;
        }
}

You might want to set up a nice-looking discourse_offline.html – unluckily, I only have an ugly one :wink:

This will not take care of the 502 Bad Gateway served by Discourse itself while it is starting up, though.

8 Likes