# Trouble configuring discourse with reverse proxy

**URL:** https://meta.discourse.org/t/trouble-configuring-discourse-with-reverse-proxy/239186
**Category:** Self-hosting
**Created:** [September 16, 2022, 8:51am UTC](https://meta.discourse.org/t/trouble-configuring-discourse-with-reverse-proxy/239186 "2022-09-16T08:51:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bloodshot\_pico](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bloodshot_pico/32/151594_2.png) [@bloodshot\_pico](https://meta.discourse.org/u/bloodshot_pico)
#### Post date: [September 16, 2022, 8:51am UTC](https://meta.discourse.org/t/trouble-configuring-discourse-with-reverse-proxy/239186/1 "2022-09-16T08:51:24Z")

</div>

Installed Wikijs (Docker compose) and Discourse.

Wikijs was working fine, had the reverse proxy working too.  
Started to install Discourse and it was having a hiccup. So I researched and found out it might be something to do with the docker installation when you install Ubuntu for the first time.

So I stopped the Wikijs docker to update. Reinstalled everything from Dockers repo. Started up Wikijs and there wasn’t any errors that I could see.  
Also booted up Discourse this time and it ran through the entire boot sequence. So I try accessing the sites. Nginx is on another server so I haven’t touched the reverse proxies. Guess what? I can’t access them from both the domain names or the localip:port.

I’m completely confused to what it is since they’re both saying they’re running and Wikijs was letting me connect earlier. I was this close. :') Syslog doesn’t say anything about these two either.

Below is some more info.

Reverse proxies:

```plaintext
server {
        listen 80;
        listen [::]:80;

        root /var/www/website.co.uk/html;
        index index.html index.htm index.nginx-debian.html;

        server_name website.co.uk www.website.co.uk;

        location / {
                rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
                rewrite ^/(.*)/$ /$1 permanent;
                try_files $uri/index.html $uri.html $uri/ $uri =404;
        }

        location /css {
                alias /var/www/website.co.uk/html/css;
        }

        location /images {
                alias /var/www/website.co.uk/html/media/images;
        }

        location /videos {
                alias /var/www/website.co.uk/html/media/videos;
        }

        location /music {
                alias /var/www/website.co.uk/html/media/music;
        }

        location /fonts {
                alias /var/www/website.co.uk/html/media/fonts;
        }

        location /scripts {
                alias /var/www/website.co.uk/html/scripts;
        }
}

server {
        listen 80;
        server_name wiki.website.co.uk;

        #ssl_certificate /etc/nginx/cert.crt;
        #ssl_certificate_key /etc/nginx/cert.key;

        #ssl on;
        #ssl_session_cache builtin:1000 shared:SSL:10m;
        #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        #ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        #ssl_prefer_server_ciphers on;

        location / {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;

                proxy_pass http://internalip:port;
                proxy_read_timeout 90;

                proxy_redirect http://127.0.0.1 https://internalip:port;
        }
}
server {
        listen 80;
        server_name forums.website.co.uk;

        #ssl_certificate /etc/nginx/cert.crt;
        #ssl_certificate_key /etc/nginx/cert.key;

        #ssl on;
        #ssl_session_cache builtin:1000 shared:SSL:10m;
        #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        #ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        #ssl_prefer_server_ciphers on;

        location / {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;

                proxy_pass http://internalip:port2;
                proxy_read_timeout 90;

                proxy_redirect http://127.0.0.1 https://internalip:port2;
        }
}

```

Tunnel is installed on the same machine as Discourse and Wikijs but I doubt that’s the issue since I’ve had it on a while now without hiccups.  
When visiting the forums I’m greeted with Bad gateway. And with the wiki I get a 504 timeout form Nginx.

Any help with this would be mostly appreciated. 🙂  
Thanks, Blood.

---

<div class="post-metadata">

### Author: ![bloodshot\_pico](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bloodshot_pico/32/151594_2.png) [@bloodshot\_pico](https://meta.discourse.org/u/bloodshot_pico)
#### Post date: [September 16, 2022, 9:43am UTC](https://meta.discourse.org/t/trouble-configuring-discourse-with-reverse-proxy/239186/2 "2022-09-16T09:43:01Z")

</div>

Inside the app.yml do I change these ports:

```plaintext
expose:
  - "80:80" # http
  - "443:443" # https

```

to something like:

```plaintext
expose:
  - "8000:80" # http
  - "8080:443" # https

```

8000 being the port I want it to look for from the main Nginx machine.  
It’s the one thing I have in mine and well I tested and doesn’t seem to work. (Rebuilt the Discourse App).

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 16, 2022, 10:39am UTC](https://meta.discourse.org/t/trouble-configuring-discourse-with-reverse-proxy/239186/3 "2022-09-16T10:39:44Z")

</div>

See [Run other websites on the same machine as Discourse](https://meta.discourse.org/t/run-other-websites-on-the-same-machine-as-discourse/17247)

You need to remove the ssl and let’s encrypt templates. Your nginx needs to do ssl and discourse needs just port 80 for the proxy to connect to.

---

<div class="post-metadata">

### Author: ![bloodshot\_pico](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bloodshot_pico/32/151594_2.png) [@bloodshot\_pico](https://meta.discourse.org/u/bloodshot_pico)
#### Post date: [September 16, 2022, 3:28pm UTC](https://meta.discourse.org/t/trouble-configuring-discourse-with-reverse-proxy/239186/4 "2022-09-16T15:28:05Z")

</div>

Would this work for the same home network and not so much the same machine due to them not actually being on the same machine? 🙂

I’m assuming this has something to do with how I fix this?  
" You cannot use `./discourse-setup` to set up Discourse if another server is using port 80 or 443. You will need to copy and edit `samples/standalone.yml` with your favorite text editor."  
That’s from the guide provided. Since I’m running Nginx on that different server that is.
