Confirmation link contains port


(Simevo) #1

the discourse instance is running on cloud_server_somewhere at port 3000 and proxied to forum.example.com at the standard http port 80

we have:

hostname = "forum.example.com"

is set in config/discourse.conf

account activation emails are sent with the link to confirm and activate the new account
the hostname is OK but it still has the port, as in:

http://forum.example.com:3000/users/activate-account/34aa

whereas we’d like to have:
http://forum.example.com/users/activate-account/34aa

how can we achieve that ? thanks !


(Jeff Atwood) #2

Looks like you have set the developer only site setting to specify the port. This will cause problems on a production site.


(Simevo) #3

Thanks for the quick reply. The server is currently in development mode. I must confess that we followed the deprecated Discourse Ubuntu Install Guide !

Browsing the code it appears that the link is generated from this template:

%{base_url}/users/activate-account/%{email_token}.

So the presence of the 3000 port in the hostname must be a consequence of an incorrectly set base_url. Searching meta.discourse.org for base_url I find similar conversations like this one.

I’ll report back what happens when we switch to production, hopefully the problem will go away then. From this test its seems it could:

bin/rails c
Loading development environment (Rails 4.1.10)
[1] pry(main)> GlobalSetting.hostname
=> "forum.example.com"
[2] pry(main)> Discourse.current_hostname
=> "forum.example.com"
[3] pry(main)> RailsMultisite::ConnectionManagement.current_hostname
=> "forum.example.com"
[4] pry(main)> Discourse.base_url
=> "http://forum.example.com:3000"
^D

RAILS_ENV=production bin/rails c
Loading production environment (Rails 4.1.10)
irb(main):001:0> GlobalSetting.hostname
=> "forum.example.com"
irb(main):002:0> Discourse.current_hostname
=> "forum.example.com"
irb(main):003:0> RailsMultisite::ConnectionManagement.current_hostname
=> "forum.example.com"
irb(main):004:0> Discourse.base_url
=> "http://forum.example.com"

(eriko) #4

You will get much less support running bare metal as everything is designed for a docker based production environment. I ran bare metal for a close to two years as my instance predated the docker setup. It made doing updates a bit of a pain and pretty manual compared to the docker based update. Also if you are ever going to need to do multisite (one codebase many sites) It is much easier in docker to do all the updates at once.