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
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.
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:
 pry(main)> SiteSetting.where('value LIKE ?', "%unix\.com%").count
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)
127.0.0.1:6379> KEYS *unix*
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)
 pry(main)> GlobalSetting.as_json
Following @pfaffman’s link I realized that I used
DISCOURSE_HOST instead of
@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!
@pfaffman could you please
rebuild HTML for ActivityPub Support: Phase 1 RFC to confirm the fix?
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
Maybe someday someone might change that config default to read:
hostname = "www.hostname-missing-check-yml-file.com"
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.
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
Button has been pushed. Looks like the image is showing up!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.