CloudFront لا يقوم بتخزين الملفات الثابتة مؤقتًا

مرحبًا.

لقد قمت بإعداد نسخة Discourse v2.3.0.beta2 على AWS.

يوضح هذا المرفق كيفية نشره. أستخدم صورة Docker الرسمية في كل مثيل ضمن مجموعة التوسع التلقائي.

لدي توزيعان لـ CloudFront:
الأول (cdn.civicxclub.com) يشير إلى سلات S3 لتقديم الصور المرفوعة مباشرة من CDN. هذا يعمل.
الثاني (civicxclub.com) يشير إلى الموزع لتقديم التطبيق وجميع الملفات الثابتة منه. هذا لا يعمل.
هذا هو تكوين السلوكيات الذي لدي:

التكوين الافتراضي يحتوي على خيار “التخزين المؤقت بناءً على رؤوس الطلب المحددة” مضبوط على الكل لمنع التخزين المؤقت من الخادم الخلفي.
جميع التكوينات الأخرى تحتوي على خيار “التخزين المؤقت بناءً على رؤوس الطلب المحددة” مضبوط على القائمة البيضاء، وأقوم بإضافة Host و Origin و Referer إلى القائمة البيضاء.

عندما أصل إلى الموقع من المتصفح وأفحص الرؤوس، على سبيل المثال لرمز المستخدم، يظهر دائمًا “Miss من CloudFront”، ولكن عندما أصل إلى الملف مرتين مباشرة من المتصفح، يظهر “Hit من CloudFront”، مما يعني أن التخزين المؤقت يعمل، لكنه لا يعمل عند تحميل الملفات من صفحة المنتدى.

تم تعيين متغير CDN الخاص بـ Discourse كالتالي:

  DISCOURSE_CDN_URL: https://civicxclub.com

هل لديك أي أفكار؟

شكرًا مقدّمًا، تحياتي.

You’re doing it wrong!

You need to split the container into Data and Web or you can use RDS for Postgresql to host data and load-balance among the web containers.

Also, It is not recommended to use cloudflare optimizations as they cause many issues.

And You need to set up your cloudfront URL in the discourse CDN field not the name of the server.

I deploy the web only container on the EC2 servers. The database is outside, on an RDS instance, as well as the Redis.

I have a CloudFront for uploads (the setting is on admin panel, and it works) and other for serving the whole webpage.

Now, I’m looking into the static headers, and it seems to work, some files yes, some don’t.

DISCOURSE_CDN_URL should be different from the DISCOURSE_HOSTNAME. Use a dedicated URL for the CDN.

Also, in our experience making all traffic go into the cloudfront tunnel increases the latency.

4 إعجابات

Nobody said anything about cloudflare. Read more closely?

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

Maybe I mis-read title as cloudflare.

إعجابَين (2)

How can I then serve avatars, css and js files from this CDN if they are stored on the server??
I’ve tried to use the cdn.civicxclub.com url which is mapping to the S3 bucket and add all the behaviours related to discourse static content, and it failed.

Please read our CDN guide:

3 إعجابات