غير اسم النطاق أو أعِد تسمية 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، فستحتاج إلى تعيين عنوان IP للمجال الجديد قبل تشغيل ./discourse-setup لمنع فشل التحقق من المجال المروع، يا إلهي.

باستخدام اصطلاح talk.foo.comtalk.bar.com

Hostname for your Discourse? [talk.foo.com]: talk.bar.com

Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname: talk.bar.com.
WARNING: Connection to http://talk.bar.com (port 80) also fails.

إعجابَين (2)

مرحباً @philh،

شكراً لك على ذكر هذا:

هذا صحيح، وإذا قمت بتشغيل ./discourse-setup وأدخلت معلومات النطاق الجديد بدلاً من تعديل app.yml، فستحتاج إلى إعداد سجلات DNS لنطاقك الجديد أولاً.

تم تحديث هذه المعلومات في الدليل لتعكس الترتيب الصحيح لتحديث النطاق في هذا الموقف. :slightly_smiling_face:

إعجاب واحد (1)

شكراً سارة!

بالمناسبة: أنا متأكد من أن هناك فحصًا للنطاق أثناء إعادة البناء يتم تشغيله ./launcher rebuild app :wink: والذي سيشير إلى أنه يجب تحديث نظام أسماء النطاقات أولاً، سواء كان ذلك عن طريق التحرير المباشر لـ app.yml أو ./discourse-setup
شكراً مرة أخرى على العمل للحفاظ على الأمور مرتبة. التعليمات المحدثة تساعد الأشخاص الجدد الذين يأتون. :slight_smile:

إعجابَين (2)

أريد أن أفعل هذا، لكنني أستخدم Digital Ocean، ولست خبيرًا. هل هناك أي شيء أحتاج إلى تغييره هناك؟

على سبيل المثال، أرى هذا:

لكنني أعتقد أن هذا مجرد اسم أعطيته له، وليس إعدادًا حقيقيًا؟

لذا طالما أنني أتبع التعليمات الموجودة في هذه الصفحة، فلن أضطر إلى إجراء أي تغييرات في Digital Ocean (ربما بخلاف تحديث هذا الاسم إلى النطاق الجديد، لتجنب الارتباك؟)

لجعل موقعك الجديد يعمل بشكل صحيح، تحتاج إلى تحديث إعدادات DNS لدى مزود اسم النطاق الخاص بك.


مثال:

إذا كان موقعك السابق هو:

forum.example.com1.1.1.1

فستحتاج إلى تغييره إلى:

forum.newname.com1.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. ابحث عن السجل A أو CNAME الحالي لـ forum.
  5. قم بتحريره:
    • الاسم: forum
    • المحتوى: 1.1.1.1 (أو عنوان IP الخاص بالخادم الخاص بك)
  6. انقر فوق حفظ.

:yellow_circle: GoDaddy

  1. قم بتسجيل الدخول إلى حساب GoDaddy الخاص بك.
  2. انقر فوق Domains، ثم حدد النطاق الخاص بك.
  3. ضمن Additional Settings، انقر فوق Manage DNS.
  4. قم بالتمرير إلى قسم Records.
  5. ابحث عن السجل A أو CNAME لـ forum، وانقر فوق أيقونة Edit.
  6. قم بتحديث ما يلي:
    • Host: forum
    • Points to: 1.1.1.1
  7. انقر فوق Save.

:orange_circle: Namecheap

  1. قم بتسجيل الدخول إلى حساب Namecheap الخاص بك.
  2. انتقل إلى Domain List ← انقر فوق Manage بجوار النطاق الخاص بك.
  3. افتح علامة التبويب Advanced DNS.
  4. ضمن Host Records، ابحث عن الإدخال الذي يحتوي على forum.
  5. انقر فوق Edit، وقم بتحديث:
    • Host: forum
    • Value: 1.1.1.1
  6. انقر فوق علامة الصح الخضراء لتأكيد التغيير.

قد تستغرق تغييرات DNS من بضع دقائق إلى 48 ساعة حتى تنتشر بالكامل، اعتمادًا على مزود الخدمة وإعدادات TTL الخاصة بك.

:three_o_clock: ملاحظة: تم إنشاء خطوات تغيير DNS باستخدام الذكاء الاصطناعي، وقد تختلف أو تحتوي على أخطاء.

إعجاب واحد (1)

كانت مشكلتي في الواقع تتعلق بـ Digital Ocean، وليس بنظام أسماء النطاقات (DNS)، والذي تمكنت من تغييره بسهولة في Cloudflare. لقد اكتشفت أنه لم يكن من الضروري إجراء أي تغييرات في Digital Ocean، على الرغم من ذلك.

شكرًا لك على ردك، على أي حال!

إعجاب واحد (1)