Redirect to my-host.com on Login


(T. H. Wright) #1

When users log in to my Discourse installation, they are being redirected to a literal “my-host.com”. The site’s source shows the following.

Personal Site Source
<style>
  @font-face {
    font-family: 'FontAwesome';
    src: url('/assets/fontawesome-webfont-ff82aeed6b9bb6701696c84d1b223d2e682eb78c89117a438ce6cfea8c498995.woff2?https://my-host.com&amp;2&v=4.5.0') format('woff2'),
         url('/assets/fontawesome-webfont-c812ddc9e475d3e65d68a6b3b589ce598a2a5babb7afc55477d59215c4a38a40.woff?https://my-host.com&amp;2&v=4.5.0') format('woff');
  }
</style>

I notice that meta.discourse.org’s reads as follows.

Meta Discourse Site Source
<style>
  @font-face {
    font-family: 'FontAwesome';
    src: url('https://d11a6trkgmumsb.cloudfront.net/assets/fontawesome-webfont-ff82aeed6b9bb6701696c84d1b223d2e682eb78c89117a438ce6cfea8c498995.woff2?https://meta.discourse.org&amp;2&v=4.5.0') format('woff2'),
         url('https://d11a6trkgmumsb.cloudfront.net/assets/fontawesome-webfont-c812ddc9e475d3e65d68a6b3b589ce598a2a5babb7afc55477d59215c4a38a40.woff?https://meta.discourse.org&amp;2&v=4.5.0') format('woff');
  }
</style>

At first I thought I was looking at a security breach, but my guess would be a setting isn’t properly set somewhere. My site loads on the domain it is supposed to and the docker container reports as follows for its hostname.

root@host-app:/# cat /etc/hostname
host-app

Looking over the admin’s backend I am not seeing a setting referencing my-host.com. Production logs are showing redirects for the logins to the site. Is there a setting that is perhaps missing in my app.yml or something I’m not seeing in the backend?


Edit:
I adjusted the variable, which I found located in the following and the site now reports the proper value in the page’s source, but the redirect still occurs.

/var/www/discourse/app/views/common/_special_font_face.html.erb

This seems to be the host_with_port variable in the software and for some reason it isn’t set. Is there a way I could push this to the container or add a value to the app.yml? Rebuilding the container caused no change. I am running Discourse 1.7.3 +1 on CentOS 7.3.


I adjusted the app.yml as well in order to report the correct hostname, but no change.

root@forums:/var/www/discourse# hostname
forums.domain.tld

Edit 2: Here is a sample production.log entry.

Started POST "/login" for 127.0.0.1 at 2017-02-21 20:19:58 +0000
Processing by StaticController#enter as HTML
  Parameters: {"username"=>"username", "password"=>"[FILTERED]", "redirect"=>"https://forums.domain.tld/"}
Redirected to https://my-host.com/
Completed 302 Found in 5ms (ActiveRecord: 1.6ms)
Started GET "/" for 127.0.0.1 at 2017-02-21 20:20:01 +0000

(T. H. Wright) #3

Resolved this. There was a setting in the server’s web server configuration which was passing an x-forwarded-host; this variable had not been altered from the placeholder value of my-host.com.