# Discourse + Nginx reverse Proxy

**URL:** https://meta.discourse.org/t/discourse-nginx-reverse-proxy/82232
**Category:** Self-hosting
**Created:** [5 maart 2018 om 15:45 UTC](https://meta.discourse.org/t/discourse-nginx-reverse-proxy/82232 "2018-03-05T15:45:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Seferi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seferi/32/78808_2.png) [@Seferi](https://meta.discourse.org/u/Seferi)
#### Post date: [5 maart 2018 om 15:45 UTC](https://meta.discourse.org/t/discourse-nginx-reverse-proxy/82232/1 "2018-03-05T15:45:33Z")

</div>

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](http://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!

---

<div class="post-metadata">

### Author: ![Vaping\_Community](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vaping_community/32/89248_2.png) [@Vaping\_Community](https://meta.discourse.org/u/Vaping_Community)
#### Post date: [5 maart 2018 om 15:53 UTC](https://meta.discourse.org/t/discourse-nginx-reverse-proxy/82232/2 "2018-03-05T15:53:19Z")

</div>

Maybe this can help..

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247):
>
> @pfaffman edited this heavily 2022.02.24. Blame me if it’s broken. If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX or HAProxy proxy in front of the Docker container. NOTE: This is for advanced admins This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working. You cannot use ./discourse-setup to set up Discourse if another server is using port 80 or 443. You will…

---

<div class="post-metadata">

### Author: ![caskd](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/caskd/32/119984_2.png) [@caskd](https://meta.discourse.org/u/caskd)
#### Post date: [5 maart 2018 om 20:16 UTC](https://meta.discourse.org/t/discourse-nginx-reverse-proxy/82232/3 "2018-03-05T20:16:14Z")

</div>

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;`

---

<div class="post-metadata">

### Author: ![Seferi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/seferi/32/78808_2.png) [@Seferi](https://meta.discourse.org/u/Seferi)
#### Post date: [6 maart 2018 om 09:16 UTC](https://meta.discourse.org/t/discourse-nginx-reverse-proxy/82232/4 "2018-03-06T09:16:26Z")

</div>

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