Discourse + Nginx reverse Proxy

AI-generated summary

A user, Seferi, is running a Discourse instance on a server behind an Nginx reverse proxy on a Raspberry Pi, with Let’s Encrypt SSL. While Nextcloud works fine, Discourse returns a 500 error when accessed via the domain. The initial Nginx configuration includes a redirect from HTTP to HTTPS and a proxy pass to Discourse’s local address. Other users suggest checking the Discourse documentation for running other websites on the same machine 17247 and adding a specific proxy redirect configuration. Seferi later notes that the issue resolved itself after a few hours, but after restoring a backup via the web UI, they can no longer log in, prompting them to open a new topic for this new issue.

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!

Maybe this can help..

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..