# Setting up offline page

**URL:** https://meta.discourse.org/t/setting-up-offline-page/81462
**Category:** Self-hosting
**Created:** [February 25, 2018, 8:49am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462 "2018-02-25T08:49:19Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 25, 2018, 8:49am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/1 "2018-02-25T08:49:19Z")

</div>

So im following this guide to setup a offline page for when the forum goes down for whatever reason but ive run into 2 issues. The two issues im running into are that nginx is not redirecting 502 errors to the offline page and when both discourse and nginx are running i cant reach the forums.

> [@Add an offline page to display when Discourse is rebuilding or starting up](https://meta.discourse.org/t/adding-an-offline-page-when-rebuilding/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 …

`/etc/nginx/sites-available/default.conf`  
[https://paste.fedoraproject.org/paste/e01vmM3pkI41nlZhzuDmuA/](https://paste.fedoraproject.org/paste/e01vmM3pkI41nlZhzuDmuA/)

`/etc/nginx/nginx.conf`  
[https://paste.fedoraproject.org/paste/B032qvRECjgrsvcjXCWc7g](https://paste.fedoraproject.org/paste/B032qvRECjgrsvcjXCWc7g)  
NOTE: i added the `include /etc/nginx/site-available/*.conf;` line because it would only load the default config

`/var/discourse/containers/app.yml`  
[https://paste.fedoraproject.org/paste/DQxhGWvfD7MBUyYWGTpqxQ/](https://paste.fedoraproject.org/paste/DQxhGWvfD7MBUyYWGTpqxQ/)

Any tips or advice for what i might be doing wrong?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 25, 2018, 9:44am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/2 "2018-02-25T09:44:00Z")

</div>

Weird! Are you 100% sure you’re talking to the right Nginx, and it is indeed reading the configuration you provide? When in doubt, I tend to replace everything in `location /` with something like `return 410;` (or some other unusual status code), checking whether I’m really served that status code.

---

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 25, 2018, 9:52am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/3 "2018-02-25T09:52:17Z")

</div>

i am indeed talking to the right nginx. Replacing everything in `location /` with return 410 results in a 410 error code

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 25, 2018, 10:28am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/4 "2018-02-25T10:28:45Z")

</div>

Hm, too bad, that’s always a nice and easy explanation 😉

Next, I’d try to debug this:

> [@dje4321](#):
>
> when both discourse and nginx are running i cant reach the forums

What happens if you try to access Discourse? What do the outer Nginx’s log files tell you about the request? Does anything show up in the log files withing Discourse’s container?

---

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 25, 2018, 10:35am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/5 "2018-02-25T10:35:00Z")

</div>

Totally forgot logs were a thing XD

nginx access.log when i try and access the domain

```plaintext
REDACTED - - [25/Feb/2018:10:30:53 +0000] "GET / HTTP/1.1" 502 173 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0" "-"
REDACTED - - [25/Feb/2018:10:30:54 +0000] "GET /service-worker-49bb49a79c0c56d327e5dc0c32ba4b6469a79f13f05a5e174c02f8cb5b1df7b3.js HTTP/1.1" 502 173 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0" "-"

```

error.log tells a different story

```plaintext
2018/02/25 10:30:54 [crit] 15312#15312: *15 connect() to unix:/var/discourse/shared/standalone/nginx.http.sock failed (13: Permission denied) while connecting to upstream, client: REDACTED server: forum.cubedcorps.net, request: "GET /service-worker-49bb49a79c0c56d327e5dc0c32ba4b6469a79f13f05a5e174c02f8cb5b1df7b3.js HTTP/1.1", upstream: "http://unix:/var/discourse/shared/standalone/nginx.http.sock:/var/www/errorpages/discourse_offline.html", host: "forum.cubedcorps.net"

```

nothing in the discourse logs

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 25, 2018, 10:51am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/6 "2018-02-25T10:51:36Z")

</div>

Okay, so something about the socket is fishy. Does the file `/var/discourse/shared/standalone/nginx.http.sock` exist (while Discourse is running)?

Did you rebuild Discourse after modifying `app.yml`?

---

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 25, 2018, 10:53am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/7 "2018-02-25T10:53:07Z")

</div>

> [@fefrei](#):
>
> Okay, so something about the socket is fishy. Does the file /var/discourse/shared/standalone/nginx.http.sock exist (while Discourse is running)?

permission | size | owner | group | date | name

srw-rw-rw-@ 0 root root 25 Feb 8:33 nginx.http.sock

> [@fefrei](#):
>
> Did you rebuild Discourse after modifying app.yml?

several times XD

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 25, 2018, 1:47pm UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/8 "2018-02-25T13:47:45Z")

</div>

Hm, in that case, I’m currently out of ideas. That looks fine, but obviously Nginx is having trouble connecting to it… 🤔

---

<div class="post-metadata">

### Author: ![notriddle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/notriddle/32/133055_2.png) [@notriddle](https://meta.discourse.org/u/notriddle)
#### Post date: [February 25, 2018, 6:14pm UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/9 "2018-02-25T18:14:01Z")

</div>

Are you running with SELinux or AppArmor on the host system?

---

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 25, 2018, 7:21pm UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/10 "2018-02-25T19:21:59Z")

</div>

yes

---

<div class="post-metadata">

### Author: ![notriddle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/notriddle/32/133055_2.png) [@notriddle](https://meta.discourse.org/u/notriddle)
#### Post date: [February 25, 2018, 7:31pm UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/11 "2018-02-25T19:31:50Z")

</div>

Try turning it off, then.

---

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 25, 2018, 8:14pm UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/12 "2018-02-25T20:14:31Z")

</div>

Cool. That solved my issue. Only thing left is to figure out why nginx wont redirect 502 errors now

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 26, 2018, 8:00am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/13 "2018-02-26T08:00:34Z")

</div>

Wohoo! Thanks, @notriddle!

The rest should be easy. You’re missing this bit of configuration:

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

```

Without it, Nginx cannot find the error page it should serve 🙂

---

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 26, 2018, 8:05am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/14 "2018-02-26T08:05:31Z")

</div>

i added the line but it does not seem to work

[https://paste.fedoraproject.org/paste/DS781CCQ7vCuDMgT2ZD19Q](https://paste.fedoraproject.org/paste/DS781CCQ7vCuDMgT2ZD19Q)

i did restart nginx to apply the change

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 26, 2018, 8:22am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/15 "2018-02-26T08:22:04Z")

</div>

Your `error_page` directive also differs from the one in my instructions, you’ll need to correct that.

However, I also get a 403 when browsing [https://forum.cubedcorps.net/errorpages/discourse\_offline.html](https://forum.cubedcorps.net/errorpages/discourse_offline.html), so there must be some additional problem. Having a look at the Nginx log files might help you here 🙂

---

<div class="post-metadata">

### Author: ![dje4321](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dje4321/32/78454_2.png) [@dje4321](https://meta.discourse.org/u/dje4321)
#### Post date: [February 26, 2018, 8:48am UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/16 "2018-02-26T08:48:20Z")

</div>

> [@fefrei](#):
>
> However, I also get a 403 when browsing [https://forum.cubedcorps.net/errorpages/discourse\_offline.html](https://forum.cubedcorps.net/errorpages/discourse_offline.html), so there must be some additional problem. Having a look at the Nginx log files might help you here 🙂

Selinux was just being a pain still XD

> [@notriddle](#):
>
> Are you running with SELinux or AppArmor on the host system?

> [@notriddle](#):
>
> Try turning it off, then.

Thanks for all your help 😃  
Never used nginx before and this was a great learning experince

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:37pm UTC](https://meta.discourse.org/t/setting-up-offline-page/81462/17 "2024-06-08T12:37:45Z")

</div>

This topic was automatically closed after 2295 days. New replies are no longer allowed.
