Showing a "Under maintenance" page using nginx at the "launcher rebuild app"?

The site maintenance with “./launcher rebuild app” takes some time to fully rebuild the site (installing new plugins etc from git).
Is there any recommended way to show a static page saying “Under maintenance” while I rebuild the discourse?

What I thought was to use nginx. That involves stopping the docker to serve on port 80 and letting nginx reverse proxy to takeover and redirect traffic to either docker container or to my static page.

I’m thinking of doing that with manually editing the nginx.conf to the following whenever needed,

server {
    listen 80;
    server_name your-discourse-domain.com;

location / {
    proxy_pass http://localhost:80;
    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 https;
    proxy_redirect http:// https://;
}
}

and replacing with,

server {
    listen 80;
    server_name your-discourse-domain.com;

    location / {
        root /path/to/your/maintenance/page;
    }
}

What are your suggestions? I’m using AWS EC2 servers. Is there any better way?

Hi @PrettyGirl

There is, yes. Take a look here:

1 Like

The way I think is better and easier is to use a two container setup so you can build a new container while the old one runs. There is much less down time that way. Others think that running an extra web server is easier.

1 Like

That will work in a lot of cases, but is still going to experience downtime whenever the data container needs to be updated.

1 Like

Major database upgrades happen less than once a year. Minor database upgrades don’t take very long and you can rebuild the data container, destroy and start the web container in a very few minutes. It seems that some people would rather have a pretty message saying that the site is down rather than reducing down time, so a second container is the way to do it.

Actually, maybe the easiest solution would be to just have a second nginx container with a “back soon” message that you ran by hand while doing an upgrade, like

./launcher stop app
docker run nginx --name back-soon # and some more stuff to see that a page was served
./launcher bootstrap app
./launcher destroy app
docker stop back-soon
./launcher start app

But then you have to get a cert and keep the cert updated for the back-soon container, which is complicated.

EDIT: Here is the canonical topic for this discussion Add an offline page to display when Discourse is rebuilding or starting up - #83 by amotl