[英]Serve S3 behind cloudfront with 2 origins
我有 2 個來源的 CF 發行版:
此分配有一個備用 CNAME。
根據路徑,我希望 S3 提供一些文件,而 ALB 提供其他文件。
我有以下路徑的 3 種行為:
assets/*
以 S3 為來源uploads/*
以 alb 為原點default
具有相同的uploads/*
的來源,但具有不同的緩存策略在 S3 存儲桶中有 2 個文件夾: svg
和v2
當我嘗試
curl -I https://myalternate.domain.name/assets/svg/mysvg.svg
或curl -I https://xxxxxx.cloudfront.net/assets/svg/mysvg.svg
我有404。
如果我從 web 得到它們,我可以看到
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>myalternate.domain.name or cloudfront endpoint</BucketName>
<RequestId>Q7Z1NAP8HV0PCEM4</RequestId>
</Error>
對於其他路徑,一切都很好。
我錯過了什么?
What the CloudFront does when it receives the https://myalternate.domain.name/assets/svg/mysvg.svg
request is that it will fetch the object stored in S3 using the key assets/svg/mysvg.svg
. 這就是它返回 404 的原因,因為 object 的實際鍵是svg/mysvg.svg
。 解決方案是向 S3 中的每個 object 添加assets/
前綴,或者使用 Lambda@Edge function 重寫源請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.