Change the domain name or rename your Discourse

:bookmark: This guide explains how-to change the domain name of your Discourse site, and includes information about setting up DNS changes, editing configuration files, updating site settings, and correcting social logins and post content to reflect your new domain name.

:warning: This guide is for self-hosted Discourse instances that were installed using our installation guide on GitHub. If you are hosted by Discourse, please see Configure your domain name for hosted Discourse for specific instructions.

You may eventually want to change the domain name of your Discourse instance, from say

=BEFORE==AFTER=

Let’s get started.

Setting the DNS TTL low in advance

First, change the Time-To-Live (TTL) setting for your DNS to a low value like 60 minutes. This should be done days ahead of the actual domain change to ensure the change can propagate quickly across the internet.

Remove old domain name from any site settings

Visit /admin/site_settings in your Discourse admin interface, and search for any settings containing the old domain name. Update these settings to the new domain name.

Changing DNS Records

Update your DNS settings to disable the old domain and point the new domain to the IP address of your Discourse server.

Editing the site name in app.yml

You can edit the app.yml file manually to input the new domain information.

Here’s how to edit it manually:

cd /var/discourse
nano containers/app.yml

Locate the following line and replace it:

DISCOURSE_HOSTNAME: 'your.newdomain.com'

If using a Content Delivery Network (CDN), temporarily disable it by commenting out the respective line in app.yml. Rebuild your Discourse site with:

./launcher rebuild app

:information_source: Alternatively, you can run ./discourse-setup again and input the new domain information instead of editing app.yml.

Check that your site is operational under the new domain.

Fixing social logins

:exclamation: Depending on how you logged in, you may need to do this first or you won’t be able to log in once the name is changed.

If you use social logins, update the credentials on the platforms (Twitter, Facebook, Google, Yahoo, GitHub) to reflect the new domain. Look for guides on the Discourse how-to category.

Remapping domain names in posts

All the existing posts will still refer to the old domain.

You’ll need to change old domain references in your posts to the new domain:

./launcher enter app

then

discourse remap =BEFORE= =AFTER=

Alternatively, use Rake if discourse binary is unavailable, you can use the rake version:

bundle exec rake posts:remap["=BEFORE=", "=AFTER="]

Finalize with:

rake posts:rebake

This ensures that the domain name remaps in existing posts, and content is regenerated as necessary.

:information_source: If you have a CDN, remember to reactivate it post-domain change.

wondering how we created that form?

Last edited by @SaraDev 2024-12-13T00:50:25Z

Check documentPerform check on document:
「いいね!」 191

rebake する理由は本当にないのでしょうか?
remap はすでに古いURLを新しいURLにマッピングしてくれました。

「いいね!」 4

@SaraDev 整理ありがとうございます。以下をご確認いただけますでしょうか。

および

何か見落としているかもしれませんが… ./discourse-setup メソッドを使用する場合、恐ろしいドメインチェックの失敗を防ぐために、./discourse-setup を実行する前に新しいドメインの IP を設定する必要があります。

talk.foo.comtalk.bar.com の規約を使用

Discourse のホスト名? [talk.foo.com]: talk.bar.com

ドメイン名の確認中 . . .
警告: コンピューターのポート 443 は、ホスト名: talk.bar.com ではアクセスできないようです。
警告: http://talk.bar.com (ポート 80) への接続も失敗します。

「いいね!」 2

こんにちは @philh

言及いただきありがとうございます。

これは正しいです。この状況でドメインを更新する正しい順序を反映するように、この情報がガイドで更新されました。 :slightly_smiling_face:

「いいね!」 1

サラ、ありがとう!

ところで、./launcher rebuild app を実行するとドメインチェックが行われるはずなので、DNS はどちらにしても先に更新する必要があると思います。app.yml を直接編集するか、./discourse-setup を実行するかです。

整理整頓にご尽力いただき、重ねて感謝いたします。最新の説明は、新しく参加する方々にとって役立ちます。:slight_smile:

「いいね!」 2

Digital Ocean を使用しており、専門家ではありません。何か変更する必要はありますか?

例えば、これを見ました。

しかし、これは私が付けた名前であり、実際のオプションではないと思います。

このページの説明に従っている限り、Digital Ocean で何も変更する必要はありません(混乱を避けるために、この名前を新しいドメインに更新すること以外は?)。

新しいサイトを正常に機能させるには、ドメイン名プロバイダーで DNS 設定を更新する必要があります。


例:

以前のサイトが次のようだった場合:

forum.example.com → 1.1.1.1

次のように変更する必要があります:

forum.newname.com → 1.1.1.1


サブドメインまたは完全なドメインを変更しますか?

上記の例では:

  • ドメインexample.com
  • サブドメインforum

サブドメインのみを変更するか、ドメイン名を完全に変更するかによって、DNS レコードを適切に更新してください。



:label: サブドメインまたは完全なドメインを変更しますか?

上記の例では:

  • ドメインexample.com
  • サブドメインforum

サブドメインのみを変更するか、ドメイン名を完全に変更するかによって、DNS レコードを適切に更新してください。


:globe_with_meridians: DNS 設定例

:blue_circle: Cloudflare

  1. Cloudflare ダッシュボードにログインします。
  2. ドメイン(例:example.com)を選択します。
  3. DNS タブに移動します。
  4. forum の既存の A または CNAME レコードを見つけます。
  5. 編集します:
    • 名前forum
    • コンテンツ1.1.1.1 (またはサーバーの IP)
  6. 保存をクリックします。

:yellow_circle: GoDaddy

  1. GoDaddy アカウントにログインします。
  2. ドメインをクリックし、ドメインを選択します。
  3. 追加設定の下にあるDNS の管理をクリックします。
  4. レコードセクションまでスクロールします。
  5. forumA レコードまたは CNAME を見つけ、編集アイコンをクリックします。
  6. 次を更新します:
    • ホストforum
    • ポイント先1.1.1.1
  7. 保存をクリックします。

:orange_circle: Namecheap

  1. Namecheap アカウントにログインします。
  2. ドメインリスト > ドメインの横にある管理をクリックします。
  3. 高度な DNS タブを開きます。
  4. ホストレコードの下で、forum のエントリを探します。
  5. 編集をクリックし、次を更新します:
    • ホストforum
    • 1.1.1.1
  6. 緑色のチェックマークをクリックして変更を保存します。

DNS の変更が完全に伝播するには、プロバイダーと TTL 設定によって、数分から最大 48 時間かかる場合があります。

:three_o_clock: 注意: DNS 変更の手順は AI によって生成されたものであり、異なる場合やエラーが含まれている可能性があります。

「いいね!」 1

私の問題は実際にはDigital Oceanに関するもので、DNSではありませんでした。DNSはCloudflareで簡単に変更できました。とはいえ、Digital Ocean側で何か変更する必要はないと分かりました。

とにかく、ご返信ありがとうございました!

「いいね!」 1