I got example.com links. Where do they come from?

Hello,

I moved a Discourse instance from one host to another one, from multisite setup to a single host setup with a single container using backup export/import, and some links use www.example.com instead of the correct host.

How do I fix this?

I have set up DISCOURSE_HOST to the hostname, but it does not seem to fix the problem. Is there any SQL query I can do use to find occurrences of www.example.com?

1 Like

Maybe remap as described in Change the domain name or rename my Discourse??

My best guess is that somewhere along the way something got configured with that hostname. It’s hard to guess how it could have happened, though.

6 Likes

Hey @hellekin

You can quick search all your site settings for the string “example” as follows, from the Rails console:

SiteSetting.where('value LIKE ?', "%example%")

For example, on our Discourse instance:

[1] pry(main)> SiteSetting.where('value LIKE ?', "%unix\.com%").count
=> 10

If you want to check REDIS, try (assuming your data container is in app), change it as you need to:

docker exec -it app redis-cli

Then, try something like:

127.0.0.1:6379> KEYS *example*
(empty list or set)

Another example:

127.0.0.1:6379> KEYS *unix*
1) "default:_CACHE:onebox__https://www.unix.com/man-page/linux/1/df/"
2) "ANON_CACHE_text/html,application/xhtml+xml,application/signed-exchange;v=b3,application/xml;q=0.9,*/*;q=0.8_https_community.unix.com/t/passing-variables-to-awk/150198|m=true|c=true|b=true|t=|ca=|l=_count"
3) "default:_CACHE:onebox__https://www.unix.com/aix/56317-timestamp-sh_history-using-ksh-shell.html"

To quickly view all your global settings, you can run this from the Rails console, and all the global settings will be visable (I’m sure there is a better way to do this…, but this is quick and works OK)

[1] pry(main)> GlobalSetting.as_json

HTH.

4 Likes

Following @pfaffman’s link I realized that I used DISCOURSE_HOST instead of DISCOURSE_HOSTNAME.

@neounix’s useful investigation tips did not yield any result, so I expect the first issue to lead to the current situation. I’m rebuilding the container to see…

Container rebuilt and links show formerly broken pictures, so I guess it’s solved. Thank you both!

3 Likes

@pfaffman could you please rebuild HTML for ActivityPub Support: Phase 1 RFC to confirm the fix?

1 Like

Yes, that make perfect sense now that I took a look at the code. Discourse config sets the default hostname to "www.example.com" in the config file, so if there was a mistake in the build file (like you describe @hellekin) , looks like you will get the default :slight_smile:

https://github.com/discourse/discourse/blob/a04c3004952ff228225cce28b5aa18cc45b1dfe2/config/discourse_defaults.conf#L64-L65

Maybe someday someone might change that config default to read:

hostname = "www.hostname-missing-check-yml-file.com"

:slight_smile: :slight_smile:

4 Likes

I don’t have admin rights here. If you want to confirm that embeds of your site works on other sites you can test at try.discourse.org.

I guess hostname = "please.set.DISCOURSE_HOSTNAME.env.example" would be more explicit and RFC-compliant.

Thanks, I tested it elsewhere already, just wanted this post to be updated :slight_smile:

2 Likes

Button has been pushed. Looks like the image is showing up!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.