dje4321
(Dje4321)
2018 年2 月 25 日 08:49
1
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.
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 loose 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…
[image]
…or a not-so-nice 502 error message from Nginx:
[image]
If you’re a perfectionist l…
/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 个赞
fefrei
(Felix Freiberger)
2018 年2 月 25 日 09:44
2
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 个赞
dje4321
(Dje4321)
2018 年2 月 25 日 09:52
3
i am indeed talking to the right nginx. Replacing everything in location /
with return 410 results in a 410 error code
fefrei
(Felix Freiberger)
2018 年2 月 25 日 10:28
4
Hm, too bad, that’s always a nice and easy explanation
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 个赞
dje4321
(Dje4321)
2018 年2 月 25 日 10:35
5
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
fefrei
(Felix Freiberger)
2018 年2 月 25 日 10:51
6
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 个赞
dje4321
(Dje4321)
2018 年2 月 25 日 10:53
7
permission | size | owner | group | date | name
srw-rw-rw-@ 0 root root 25 Feb 8:33 nginx.http.sock
several times XD
fefrei
(Felix Freiberger)
2018 年2 月 25 日 13:47
8
Hm, in that case, I’m currently out of ideas. That looks fine, but obviously Nginx is having trouble connecting to it…
2 个赞
notriddle
(Michael Howell)
2018 年2 月 25 日 18:14
9
Are you running with SELinux or AppArmor on the host system?
4 个赞
notriddle
(Michael Howell)
2018 年2 月 25 日 19:31
11
Try turning it off, then.
3 个赞
dje4321
(Dje4321)
2018 年2 月 25 日 20:14
12
Cool. That solved my issue. Only thing left is to figure out why nginx wont redirect 502 errors now
fefrei
(Felix Freiberger)
2018 年2 月 26 日 08:00
13
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
2 个赞
dje4321
(Dje4321)
2018 年2 月 26 日 08:05
14
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
fefrei
(Felix Freiberger)
2018 年2 月 26 日 08:22
15
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
1 个赞
dje4321
(Dje4321)
2018 年2 月 26 日 08:48
16
Selinux was just being a pain still XD
Thanks for all your help
Never used nginx before and this was a great learning experince
1 个赞
This topic was automatically closed after 2295 days. New replies are no longer allowed.