Use a different port for invites


(David Jameson) #1

I have discourse configured inside a VM behind a firewall. Port 80 is not available and I am using a different port for external access to discourse. Everything works fine except that when I send an invite to someone, the URL they receive does not have a port in it and hence they can’t connect.

I’ve been looking though configuration and settings but have not found place where I can specify the port that should be used.

Suggestions most appreciated.

D


(Felix Freiberger) #2

Running Discourse on non-standard ports isn’t supported, so there will be many pain points like this.

However, what about port 443? That one is supported provided you enable HTTPS, which you should do anyways :wink:


(Jeff Atwood) #3

(David Jameson) #4

I am running HTTPS but again, not using standard ports. Internally, Discourse is in fact running on port 443 and my firewall, when receiving requests on the external port, it forwards to the appropriate machine using port 443.

So the only issue is configuring the invitation message itself.


(Felix Freiberger) #5

So, you basically have three choices:

  1. Change something about the firewall situation.
  2. Choose a different discussion software that supports nonstandard ports.
  3. Enter the world of pain and fix these issues yourself. In that case, you probably won’t get much support here, because this setup is, well, not supported.

(David Jameson) #6

Well, I just grepped the code and found the file invite.rb which contains on line 90 (of the version I just installed a few days ago)

"#{Discourse.base_url}/invites/#{invite.invite_key}" if invite

Seems to me all I need to do is insert my desired port number into that string.

Granted, that’s a hack but I had hoped that this would have been something built into the configuration.

Other than having to fix it every time there’s an update, it’s not much pain.

I’m actually rather surprised there isn’t a “{Discourse.base_port}” variable defined. It seems to me that many people might need to run this behind a firewall with port 443 not available (or being routed to a different web server)


(David Jameson) #7

OK - for anyone else who needs to do this - you need to insert the desired port number in two files

models/invites.rb
mailers/invite_mailer.rb (two places)

Just look for

"#{Discourse.base_url}/invites/#{invite.invite_key}" if invite

and modify with your desired port, e.g.

"#{Discourse.base_url}:12345/invites/#{invite.invite_key}" if invite

Then restart Discourse and voila!


(Jeff Atwood) #8

You have also broken upgrades forever. This is not a solution, it is a new problem you’ve created for yourself.


(Jay Pfaffman) #9

Search for running discourse with other web servers.


(David Jameson) #10

I said earlier, “Other than having to fix it every time there’s an update, it’s not much pain.”

I’m aware it’s a hack. But it’s a trivial one - a simple bash script could be used to automate setting/resetting this and if I end up committing to Discourse, I’ll create such a script.

I understand completely it’s not THE way to do it - but I’m not in a position to invest time in figuring out the entire codebase just to figure out how/where to create a new “variable” such as {Discourse.base_port} and then make that work everywhere.

To paraphrase Voltaire, “Perfect is the enemy of good enough”