Setting up offline page

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.

/etc/nginx/sites-available/default.conf
https://paste.fedoraproject.org/paste/e01vmM3pkI41nlZhzuDmuA/

/etc/nginx/nginx.conf
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/

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

2 Likes

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.

2 Likes

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

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

Next, I’d try to debug this:

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?

1 Like

Totally forgot logs were a thing XD

nginx access.log when i try and access the domain

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

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

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?

1 Like

permission | size | owner | group | date | name

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

several times XD

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

2 Likes

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

4 Likes

yes

Try turning it off, then.

3 Likes

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

Wohoo! Thanks, @notriddle!

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

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

Without it, Nginx cannot find the error page it should serve :slight_smile:

2 Likes

i added the line but it does not seem to work

https://paste.fedoraproject.org/paste/DS781CCQ7vCuDMgT2ZD19Q

i did restart nginx to apply the change

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, so there must be some additional problem. Having a look at the Nginx log files might help you here :slight_smile:

1 Like

Selinux was just being a pain still XD

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

1 Like

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