Discourse + Nginx reverse Proxy

Hi,

I have a Raspberry Pi setup as a Nginx reverse proxy which is handling ssl (lets encrypt) as well and I’m running an nextcloud instance on my server and everything works fine. I installed discourse on the server and its working fine when i go to local address 192.168.178.131 but when i go to the url it loads for a few seconds and then gives me a http 500 error. What am I doing wrong that the nextcloud works and discourse not? Here is my nginx sites-available configuration:

server {
listen 80;
server_name forum.example.com;
rewrite ^ https://$host$request_uri? permanent;

}

server {

listen                     443 ssl;
server_name         forum.example.com;
ssl_certificate     /etc/letsencrypt/live/www.example.com/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;

location / {
    proxy_pass http://192.168.178.131:80;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;

  }

}

I appreciate if someone could help, I spent the whole day trying different configs to figure it out.
Thanks alot!

1 Like

Maybe this can help…

3 Likes

I would also recommend this, it is not included but for me it was necessary for it to work.
proxy_redirect http://unix:/var/discourse/shared/standalone/nginx.http.sock: https://$server_name;

Thanks for the replies. My setup magically started working after a few hours without me having to change anything… Very strange. But after i restored my backup via web ui, it doesn’t let me login anymore… Everything is restored, site appears to be working but I can’t login… But I’ll open a new topic for that I guess… Thanks again…