URLs for avatars & emoticons adding :80 to the end of the domain

Guys,

I am having an issue where some avatars are missing where you’ve quoted someone in a post.

On investigating I noticed ‘:80’ being added to the end of each domain in the image URL for some avatars, but not others. When I copied a failed image’s URL(which begins https://) into a new browser tab and removed the :80 the avatar loaded fine.

What is going wrong? Why is port 80 being used within the URL and how best to resolve this?

Interestingly when you go and edit your post, the images in the preview work fine - they are missing the ‘:80’.

Apologies for my lack of knowledge!

Thanks!

what does your DISCOURSE_HOSTNAME say in your app.yml file?

forgive me for maintaining privacy, but its basically: www.mydomain.org

btw, I think Facebook logon has been broken since forcing https too … as its redirects seem to be using port 80 too …

Do you have any sort of proxy in front of Discourse? NGINX or Apache perhaps?

NGINX is running …

This is very likely caused by something in your NGINX config then. Check out Running other websites on the same machine as Discourse for more details.

Sorry, @jomaxro, I’m not very experienced, so please forgive me, but:

root@blah:/# ps waux | grep nginx

returns:

root 4252 0.0 0.0 4244 604 ? Ss 19:21 0:00 runsv nginx
root 4257 0.0 0.1 82720 3476 ? S 19:21 0:00 nginx: master process /usr/sbin/nginx
www-data 4271 0.3 0.2 84908 5176 ? S 19:21 0:07 nginx: worker process
www-data 4272 0.3 0.2 84628 5620 ? S 19:21 0:07 nginx: worker process
www-data 4273 0.0 0.0 82888 1908 ? S 19:21 0:00 nginx: cache manager process

But i’m only running the vanilla discourse install in a docker container.

I didn’t explicitly install nginx

Does that change anything?

Yes it does. Discourse runs NGINX inside the docker container, so that might be what you’re seeing. That’s not my area of expertise, unfortunately, you’ll need to wait for someone else who can confirm if the NGINX you’re seeing is inside or outside the container.

Does the URL of a failing image start with http or https?

1 Like

https, but suffixed with :80 (which will clearly fail as https doesn’t use this port?)

e.g.: https://www.mydomain.org:80/letter_avatar_proxy/v2/letter/b/f475e1/40.png

the word ‘proxy’ is interesting!

That’s not a custom avatar URL. The default capital letters load from our CDN => https://avatars.discourse.org/v2/letter/b/f475e1/40.png

1 Like

Quite correct, I’d initially assumed it was happening to custom avatars only, now it seems to be inconsistent. Updated issue title and detail accordingly, apologies.

Here’s an example of a user avatar failing:

https://www.mydomain.org:80/user_avatar/www.mydomain.org/username/40/615_1.png

The weird part is that some are rendering correctly, others have :80 added …

It’s seems a little bit like this resolved issue, but I do not have a port number in my DISCOURSE_HOSTNAME setting:

I did a bit more digging and the problem posts seemed to have been submitted around the time I switched force_https … I’m guessing that’s the source of the problem. I’m going to try to do a remap of the posts.

Offending posts fixed with:

discourse remap mydomain.org:80/ mydomain.org/

Having looked at the logs I’m convinced that the offending posts occurred during a time I switched force_https off for a short while.

3 Likes

Oh dear this is still happening and affecting emoticons too! I can use the workaround above but something is still baking :80 into image URLs in the first place and I cannot keep running the workaround …

What does SiteSetting.port return when you type it in the rails console?

1 Like

That’s returning 80!:

root@blah-app:/var/www/discourse# rails c
SiteSetting.port
[1] pry(main)> SiteSetting.port
=> “80”

Should I set this to 443 directly? How to keep that persistent after reboot or upgrade? Where is it getting that value from?

You’ll need to set it to nil to fix it.

7 Likes

Thanks! Will try that and revert with status. Will I need to restart anything?

This seems to be resolved and no restart was required. Thanks for your help guys!

1 Like