这里有一些相关信息,我上个月也处理过这个问题。
我的解决方法是同时设置两个变量(DISCOURSE_S3_CDN_URL 和 DISCOURSE_CDN_URL),并创建两个 CloudFront 分发:一个用于上传文件,源站为 S3 存储桶;另一个用于资源文件,源站为服务器。
以下是我们使用的代码:
- 以 S3 为源站的 CloudFront 分发:infra/live/prod/services/discourse/cloudfront.tf at master · debtcollective/infra · GitHub
- 以服务器为源站的 CloudFront 分发:infra/live/prod/services/discourse/cloudfront.tf at master · debtcollective/infra · GitHub
以下是我们的 app.yml(我们将其命名为 web.yml),我们在构建时替换变量:infra/modules/services/discourse/web.yml at master · debtcollective/infra · GitHub