# Display static error page while site is down

**URL:** https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658
**Category:** Support
**Created:** [September 10, 2022, 8:47pm UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658 "2022-09-10T20:47:11Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [September 10, 2022, 8:47pm UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/1 "2022-09-10T20:47:11Z")

</div>

What I want to do is serve a page saying “this site is under maintenance” when it goes offline during, for instance, the rebuilding process.

> [@Add an offline page to display when Discourse is rebuilding or starting up](https://meta.discourse.org/t/add-an-offline-page-to-display-when-discourse-is-rebuilding-or-starting-up/45238):
>
> warning This guide is intended for advanced users, who are already using nginx outside the docker container. By following this guide you make your setup more complicated and will lose some speed benefits like HTTP2 if you’re not running Ubuntu 16.04 or later. Proceed with caution! When Discourse is rebuilding or starting up, your users will usually either see an error message from their browser… …or a not-so-nice 502 error message from Nginx: If you’re a perfectionist …

This topic is basically what I’d like to do but seems to require a nonstandard setup. Is there an easier way to do this for a standard installation? Thanks!

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [September 10, 2022, 9:02pm UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/2 "2022-09-10T21:02:33Z")

</div>

> [@piffy](#):
>
> Is there an easier way to do this for a standard installation?

No, there is not anything like that at the moment.

---

<div class="post-metadata">

### Author: ![Alexander](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alexander/32/497634_2.png) [@Alexander](https://meta.discourse.org/u/Alexander)
#### Post date: [September 10, 2022, 10:02pm UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/3 "2022-09-10T22:02:53Z")

</div>

In reality, this procedure uses what is considered a “standard installation” (i.e. using the official Discourse Docker guide), to which Nginx is redeployed outside of the container.

The procedure seems scary at first, but it really isn’t, I can help you if you want.

---

<div class="post-metadata">

### Author: ![piffy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/piffy/32/254198_2.png) [@piffy](https://meta.discourse.org/u/piffy)
#### Post date: [September 11, 2022, 12:39am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/4 "2022-09-11T00:39:11Z")

</div>

> [@Falco](#):
>
> No, there is not anything like that at the moment.

Not the answer I wanted to hear, but I appreciate the unambiguous answer nonetheless

> [@Alexander](#):
>
> In reality, this procedure uses what is considered a “standard installation” (i.e. using the official Discourse Docker guide), to which Nginx is redeployed outside of the container.
> 
> The procedure seems scary at first, but it really isn’t, I can help you if you want.

I am not too worried about the process, moreso whether this setup will require any additional considerations when doing simple things in the future like installing a new plugin. Or is it mostly something that once it’s set up I don’t have to think about it again?

---

<div class="post-metadata">

### Author: ![ClawdiaWolf](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clawdiawolf/32/262518_2.png) [@ClawdiaWolf](https://meta.discourse.org/u/ClawdiaWolf)
#### Post date: [September 11, 2022, 12:45am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/5 "2022-09-11T00:45:28Z")

</div>

> [@piffy](#):
>
> Or is it mostly something that once it’s set up I don’t have to think about it again?

Since I added NGINX for this back in 2020 I’ve had to edit the config twice. Both times it was adjust settings related to uploading large files after updating the limit in Discourse.

Using the external NGINX to provide the static page and act as a reverse proxy for Discourse normally doesn’t require changes once you have it setup properly.

---

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [September 11, 2022, 1:16am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/6 "2022-09-11T01:16:24Z")

</div>

Note that the external nginx brings something else valuable besides the static error page: Correct attribution of source IP addresses for IPv6 users. If your forum is accessible via IPv6, and you do not use the external nginx configuration, everyone accessing your site via IPv6 will show up as coming from a 172.x.y.z local address. This doesn’t help when you are trying to deal with malicious site users like spammers!

> [@piffy](#):
>
> I am not too worried about the process, moreso whether this setup will require any additional considerations when doing simple things in the future like installing a new plugin. Or is it mostly something that once it’s set up I don’t have to think about it again?

It’s _exactly the same_ for adding new plugins.

I think that it makes it easier to update because you know that your users will be made aware of maintenance and just wait for it to finish.

The one thing I can think of that you want to be sure of is that you have certbot correctly renewing your certificates. That’s built into the default configuration that doesn’t use external nginx, but if you use external nginx, you also have to use external certbot and have to make sure it is set up to renew your certificate. And not all ways of installing certbot handle this.

Note that the documentation you asked about says:

> ⏰ If you installed certbot from your package repository, renewals usually happen automatically. Otherwise, set a reminder to run `letsencrypt renew && systemctl reload nginx.service` before your certificate expires!

Setting a reminder is not a good way to do this, though. You’ll inevitably forget, and if you miss an email from letsencrypt warning you about the expiring certificate your site will quit working. Fortunately, this is easy to work around.

If automatic renewals aren’t set up, here’s how to do it.

Create the file `/etc/systemd/system/certbot.service` with these contents:

```plaintext
[Unit]
Description=Certbot
Documentation=file:///usr/share/doc/python-certbot-doc/html/index.html
Documentation=https://letsencrypt.readthedocs.io/en/latest/
[Service]
Type=oneshot
ExecStart=/usr/bin/certbot -q renew
PrivateTmp=true

```

Create the file `/etc/systemd/system/certbot.timer` with these contents:

```plaintext
[Unit]
Description=Run certbot twice daily

[Timer]
OnCalendar=*-*-* 00,12:00:00
RandomizedDelaySec=43200
Persistent=true

[Install]
WantedBy=timers.target

```

Then tell systemd about the new files.

```plaintext
# systemctl daemon-reload
# systemctl enable --now certbot.timer

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 11, 2022, 3:54am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/7 "2022-09-11T03:54:19Z")

</div>

If you use a two container setup the down time is under a minute and you don’t really need such a page.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [September 11, 2022, 7:19am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/8 "2022-09-11T07:19:35Z")

</div>

After some searches here it is quite clear that maintenance of two containers is way more demanding job than Nginx. At my level of skills anyway.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 11, 2022, 8:06am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/9 "2022-09-11T08:06:26Z")

</div>

Ah. I see. From my perspective it’s almost the she except you do have to pay attention to when the dates container needs to get updated, which is infrequent, but you do have to pay attention. And when that happens, the site is down for a while.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [September 11, 2022, 8:16am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/10 "2022-09-11T08:16:15Z")

</div>

That’s true too. It is always trade off — the time how long a forum will be down because of updates/upgrades vs. the time that maintenance of separate containers craves (and specially when you (read: I) mess up everything and start trying to find some fixes and forum is down same time 🤣 )

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 11, 2022, 8:17am UTC](https://meta.discourse.org/t/display-static-error-page-while-site-is-down/238658/11 "2022-10-11T08:17:16Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
