أسهل ما كان بالنسبة لي هو تعيين تسمية إضافية في app.yml الخاص بـ Discourse لإخبار Traefik الخاص بي بإضافة رأس X-Forwarded-Proto: https، ولكن بعد ذلك سيقوم nginx بتجاوز هذا المعامل بنسخته الخاصة.
ويلعب تكوين nginx الخاص بـ Discourse دورًا هنا:
هناك يحاول Discourse تخمين البروتوكول من الطلب الأصلي (والذي، في إعدادي، هو دائمًا نص عادي نظرًا لأن هذا هو ما يرسله Traefik). ثم يستخدم ذلك لـ تعيين X-Forwarded-Proto عدة مرات.
في النهاية، قمت بتحرير containers/app.yml الخاص بي لتثبيت هذه الرؤوس على https:
run:
- exec: echo "Beginning of custom commands"
## If you want to set the 'From' email address for your first registration, uncomment and change:
## After getting the first signup email, re-comment the line. It only needs to run once.
# - exec: rails r "SiteSetting.notification_email='no-reply@forum.cabana.network'"
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /# attempt to preserve the proto, must be in http context\nmap \$http_x_forwarded_proto \$thescheme {\n default \$scheme;\n "~https$" https;\n}/\n
to: |
# force https scheme so Discourse generates HTTPs links and redirects (ie, `/login`)
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: "$thescheme"
global: "true"
to: "https"
- exec: echo "End of custom commands"
مرة أخرى، أعتقد أنه إذا كان هناك إعداد force_https، فيجب على تطبيق Discourse-the-rails-app احترامه، بغض النظر عما يتعامل معه الوكيل العكسي أو الأطراف الأخرى أم لا.