Uploads and confirmation emails break when changing external docker port in app.yml


(Clay Heaton) #1

In app.yml, image uploads and new account verification emails break when changing from:

expose:
  - "80:80"
  - "2222:22"

to the following (9999 as an exampe):

expose:
  - "9999:80"
  - "2222:22"

if you don’t use URL rewriting to mask the external port number.

In my situation, I’m on a private internal network and want to run discourse on a server that already is hosting sites on 80 and 443. I can get to the instance of Discourse that I installed at http://www.mysite.com:9999 but when I try to upload images (into the site assets category, for example) the image paths all lack the port number.

So… I tried going back into the app.yml file and changing:

env:
  DISCOURSE_HOSTNAME: 'www.mysite.com'

to the following:

env:
  DISCOURSE_HOSTNAME: 'www.mysite.com:9999'

I then rebuilt the app. After that change, image uploads (into posts) worked, but avatar images were broken. The src for them became, for example:

src="/user_avatar/www.mysite.com:9999/system/45/1.png"

From my point of view, the expected behavior is that setting:

expose:
  - "9999:80"
  - "2222:22"

Should append the port number to all links OR I should be able to change

env:
  DISCOURSE_HOSTNAME: 'www.mysite.com:9999'

To indicate that all links should include the port number. Alternatively, perhaps we should be able to have a second setting:

env:
  DISCOURSE_HOSTNAME: 'www.mysite.com'
  DISCOURSE_PORTNUMBER: 9999        # or 80 or whatever

FYI, I first asked about this here:

https://meta.discourse.org/t/troubleshooting-email-on-a-new-discourse-install/16326/41?u=clay&source_topic_id=19994

(lid) #2

Is there any technical reason to add additional / redundant domain information into the avatar’s path.

The only place I can see this slightly beneficial is when the image is served via a CDN, but who is benefiting from it I am not sure( may be multisite?).

//cdn.discourse.org/meta/user_avatar/meta.discourse.org/clay/45/5265.png

And technically this can be replaced with random string and still serve the image. a colon is an exception
//meta.discourse.org/user_avatar/meta.discourse.org/clay/45/5265.png
301 Moved Permanently

//meta.discourse.org/user_avatar/anyrandomStringgg/clay/45/5265.png
301 Moved Permanently


(lid) #3

https://github.com/lidlanca/discourse/commit/33e179040864a4d5a0add955ee24137c251c4b62


(Clay Heaton) #4

There’s another spot where this is broken. If I implement your change and then change my app.yml to:

env:
  DISCOURSE_HOSTNAME: 'www.mysite.com:9999'

Uploads and avatar images appear to work, except for the tiny avatar images that appear when you quote somebody as part of a reply, as shown in this image:


(Sam Saffron) #5

Non default port is not really supported/tested


(Clay Heaton) #6

Fair enough. However, I’ll say that other than the minor issues with display of the profile images and/or uploads and the activation emails (as described above), everything seems to work fine.


#7

Is that still the case?


(Sam Saffron) #8

Yes

Non default port is not really supported/tested


(Clay Heaton) #9

I’ve run on a non-default port for over a year without any problems at all (related to the port). I don’t think it will be an issue for you as long as you’re properly directing traffic into the container.