If you refer to itGitHub installation guideAfter a Discourse instance is installed on the page, the user wants to modify the domain name of the Discourse instance. If you’re usingDiscourse official host serviceIf so, please referConfigure your domain name for the cloud service of DiscourseDetails on the page.
Suppose you now want to change the domain name of your Discourse instance from talk.foo.com to talk.bar.com.
Let’s start the process.
In advanced Settings for DNS, set TTL to low
You want to let everyone know that your domain name has been changed, so you can set the TTL time in your domain DNS to low, such as 60 minutes.
The main purpose of this setting is to make your DNS changes take effect faster. DNS changes over the Internet take time because of the cache.
Remove all old domain name configurations from the site
Go to /admin/site_settings and search for all the Settings for the old domain name.
If your search turns up some configuration for an old domain name, make sure you change it.
Edit Discourse configuration in app.yml file
Optionally, you can run it again
./discourse-setup
Command, and then update the new domain name toapp.yml
Configuration file.
In the app.yml file, edit the contents of hostname.
## Change the hostname of Discourse instance to the following DISCOURSE_HOSTNAME: 'talk.bar.com'Copy the code
(Also, if you use a CDN, you can comment out the CDN configuration in the app.yml file. After you’ve made the changes, uncomment it.
After completing the above configuration, it is necessary to reconstruct Discourse:
./launcher rebuild app
When you’re done with the above refactoring, your site can only be accessed through the new domain name.
Modify your DNS configuration
- Delete the DNS record of the old domain name
- Modify the DNS record of the new domain name to point to your Discourse address.
After the above configuration, you should have no problem accessing your Discourse site with the new domain name.
You can also change your DNS configuration while the site is refactoring.
It is verified that all functions can be accessed normally. When we verify functions, we want to make sure that we can log into our Discourse system normally. This is the problem that the following topic needs to solve…
Modifying third-party Login
Depending on how you log in, you need to change this right away, otherwise you won’t be able to log in through a third party once the domain is changed.
Login configurations for your Twitter, Facebook, Google, Yahoo, and GitHub social media accounts will also need to be modified to match the callbacks to your new addresses.
Please refer to the related official articles for configuration and modification.
Replace all references to the old site in the topic with the domain name of the new site
Now all the links in the topics and posts are still in the old domain name, we need to change this, the links in the posts point to the new domain name. Let’s do this:
BEFORE
AFTER
./launcher enter app
Copy the code
Then type and enter the following command:
discourse remap talk.foo.com talk.bar.com
Copy the code
Modify the parameters as prompted, and then run the following command:
rake posts:rebake
Copy the code
The remaps in the theme will now be replaced with the old domain address using the new domain address, and we regenerated all the themes to avoid missing anything.
At this point, all the configuration for changing the domain name is complete!
(If you comment out the CDN configuration at first, don’t forget to change it back.)
Want to know how the input dialog box in the topic is created?
www.ossez.com/t/discourse…