Running on different port than 443: Disable redirect to nonport URL

I’ve change app.yml
to

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

and want to open discourse via https://mydomain.com:20633, but then it tries to redirect to https://mydomain.com which won’t work.

When using

expose:
  - "20632:20632"   # http
  #- "443:443" # https
  - "20633:20633"

netstat -tulpn shows that it is listening on these ports, but when trying to access, there is a timeout.

I found running on subfolder meta . discourse . org/t/serve-discourse-from-a-subfolder-path-prefix-instead-of-a-subdomain/30507 which isn’t applicable

I found also meta . discourse . org/t/install-discourse-on-a-residential-internet-with-cloudflare-tunnel/211297
That goes in the right direction, but isn’t fully what I need.

PS Sorry for removing the links to forum, but I can’t post otherwise.

1 Like

We don’t support running on non-standard ports. If the 80/443 ports are already occupied, you will need to use a separate server where they aren’t or run a reverse proxy to from your other services and Discourse.

3 Likes

Sometimes “we don’t support” means “that’s beyond the help you can expect here”, but this time it means “you’re wasting your time even trying”.

1 Like

The ports aren’t “occupied” in the usual way. Discourse can grab port 80 and 443 on that system, it is already running on a separate server on its own.
Im stuck at the step to disable the redirection/removing the port in the URL and everything would work as expected.

1 Like

You cant prevent that redirect.

If you can’t publish on the standard ports, then it won’t work at all. Your choices here are to use a server where :80/443 are available, or to pick an alternative discussion platform.

1 Like

Can you help me with the nginx reverse proxy configuration?

I’ve tried various options without success

server {
    listen 20633 ssl;
    server_name mydomain.com;
	
	ssl_certificate /etc/letsencrypt/live/mensa.myftp.org/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/mensa.myftp.org/privkey.pem;

    location / {
        # Remove the port from the proxy_pass URL using a regular expression
        # The captured part of the regular expression ($1) will be replaced in the proxy_pass URL
        # The actual backend server IP and port are specified separately in the proxy_pass directive
        proxy_pass http://192.168.178.31:80/
		#$request_uri;
		proxy_redirect http://192.168.178.31:80/ $scheme://$host:20633/;
		#return 301 $scheme://$host:$server_port/home;
		#proxy_redirect http://192.168.178.31:20633 $scheme://$host:80;
        
        # Preserve the Host header sent by the client to the backend server
        #proxy_set_header Host $host;
		proxy_set_header Host $http_host;

    }
}
1 Like

See the guide at Run other websites on the same machine as Discourse.

2 Likes

That tutorial is for running on the same server via unix socket. Is there also configuration for running the reverse proxy on a different system with different port? I think it should be since this case might occur more often. On the other host I already have a certificate.
Just to be clear: This setup is for testing only. In production it will run on port 443, but for development and testing a VM at home is completly sufficient and saves the cost for renting a server in the meantime.