يجب إضافة عنوان URL الخاص بـ CDN إلى مصدر نص سكربت CSP

لقد قمت بتكوين موقع باستخدام متغيرات البيئة (ENV) على النحو التالي:


  DISCOURSE_FORCE_HTTPS: true
  DISCOURSE_S3_ACCESS_KEY_ID: 'KEY'
  DISCOURSE_S3_SECRET_ACCESS_KEY: 'SECRET'
  DISCOURSE_BACKUP_LOCATION: 's3'
  DISCOURSE_ENABLE_S3_UPLOADS: true
  DISCOURSE_ENABLE_S3_INVENTORY: false
  DISCOURSE_S3_BACKUP_BUCKET: 'mybucket/backups'
  DISCOURSE_S3_UPLOAD_BUCKET: 'mybucket'
  DISCOURSE_S3_CDN_URL: 'https://mybuckets3.cdn.literatehosting.com'
  DISCOURSE_S3_REGION: 'us-west-1'
  DISCOURSE_BACKUP_WITH_UPLOADS: 'false'
  DISCOURSE_CDN_URL: 'https://mybucket.cdn.literatehosting.com'

كان يعمل بشكل صحيح حتى أضفت s3 cdn url. بعد إضافة عنوان CDN الخاص بـ S3، بدأ المتصفح في رفض الطلبات الموجهة إلى CDN العادي (غير S3). أضفت عنوان CDN إلى SiteSetting.content_security_policy_script_src= وعاد كل شيء للعمل مرة أخرى. يبدو أن هذا خطأ، أليس كذلك؟ لقد قمت بإعادة التشغيل فقط بعد تغيير متغيرات البيئة هذه، وليس إعادة البناء. هل أحتاج إلى تنفيذ rake assets:precompile عند تغيير إعدادات CDN؟

Hmm, this should be working fine. The CSP is supposed to whitelist the specific folders on the S3 and pull CDNs that scripts come from.

What CSP was/is Discourse sending with the page? Is this a subfolder install?

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

I think I understand that. Is that CSP in the static assets that a rake assets:precompile makes? (But then why would adding it to the settings fix it.)

I’m afraid that I don’t quite know the canonical way to get the answer to that question.

Not subfolder. A fairly standard install, though traefik is a reverse proxy in front of it.

curl -I https://discourse.example.com/ or the Chrome inspector, and get the content of the Content-Security-Policy header.

إعجابَين (2)