Trouble configuring discourse with reverse proxy

AI-generated summary

The user bloodshot_pico is experiencing issues configuring Discourse with a reverse proxy. They have installed Wikijs and Discourse using Docker Compose and have set up Nginx on a separate server. However, they are unable to access the sites using their domain names or local IP and port. They have provided their Nginx configuration and are seeking help to resolve the issue.

bloodshot_pico wonders if they need to change the ports in the app.yml file to match the ports they want to use on the main Nginx machine.

pfaffman suggests that bloodshot_pico needs to remove the SSL and Let’s Encrypt templates and let Nginx handle SSL. Discourse only needs port 80 for the proxy to connect to.

bloodshot_pico asks if this solution would work for their setup, where the Nginx server is on a different machine than the Discourse server, but on the same home network. They are also unsure how to resolve the issue with port 80 being used by another server.

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:

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. :slight_smile:
Thanks, Blood.

Inside the app.yml do I change these ports:

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

to something like:

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

See Run other websites on the same machine as Discourse

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.

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? :slight_smile:

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.