soke
(SoKe)
2019 年2 月 22 日 12:43
1
您好。
我在 AWS 上部署了 Discourse v2.3.0.beta2 版本。
此附件展示了我的部署方式。我在自动扩展组的每个实例上都使用了官方的 Docker 镜像安装。
我配置了两个 CloudFront 分发:
一个 (cdn.civicxclub.com ) 指向 S3 存储桶,用于直接从 CDN 提供上传的图片。这可以正常工作 。
另一个 (civicxclub.com ) 指向负载均衡器,用于提供应用程序及其所有静态文件。这无法正常工作 。
以下是我配置的缓存行为:
默认行为的“基于所选请求头进行缓存”选项设置为 全部 ,以防止从后端缓存。
其他所有行为的“基于所选请求头进行缓存”选项设置为 白名单 ,并且我列出了 Host、Origin 和 Referer 头作为白名单。
当我从浏览器访问网页并检查例如头像的响应头时,它总是显示“CloudFront Miss”,但当我直接从浏览器两次访问该文件时,它显示“CloudFront Hit”。这说明缓存本身是有效的,但在从论坛网页加载文件时未能生效。
Discourse 的 CDN 变量设置如下:
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.
soke
(SoKe)
2019 年2 月 22 日 13:09
3
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.
Falco
(Falco)
2019 年2 月 22 日 14:25
4
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 个赞
soke
(SoKe)
2019 年2 月 25 日 16:17
7
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.
Falco
(Falco)
2019 年2 月 25 日 17:40
8
Please read our CDN guide:
So you’d like to use a CDN to speed up worldwide access to common assets on your Discourse forum? You might want to go all-in and Set up file and image uploads to S3 (see also Configure an S3 compatible object storage provider for uploads ).
If you want a CDN without the added complexity of S3 and having two CDNs, this is the guide for you. The CDN will reduce some load on your server by letting the CDN serve those assets so that the server doesn’t have to. It also can speed things up by deliver…
3 个赞