同一CloudFront分布中的多个S3存储桶 [英] Multiple S3 buckets in the same CloudFront distribution
问题描述
我使用带有SSL的CNAME images.domain.com
创建了一个Cloudfront发行版,我有2个S3存储桶:一个用于用户上传,一个用于产品图片默认存储桶是上传存储桶
I created a Cloudfront distribution with a CNAME images.domain.com
with SSL, and I have 2 S3 buckets: one for user uploads, one for product pictures
The default bucket is the uploads bucket
我想对两个存储桶使用相同的CloudFront
I would like to use the same CloudFront for both buckets
因此,我将这两个存储桶添加为原点,并使用产品存储桶作为原点,创建了一个路径为/products/*
的行为"
So I added the 2 buckets as origins and created a "Behavior", with the path /products/*
using my product bucket as origin
我的行为"是:
- /products/*到:产品存储桶(优先级= 0)
- 默认(*)为:上传存储桶(优先级= 1)
当我进入 images.domain.com/products/78/34.jpg
时,我得到一个AccessDenied
When I go to images.domain.com/products/78/34.jpg
I get an AccessDenied
我的产品"存储桶中存在文件"78/34.jpg"
The file "78/34.jpg" is present in my products bucket
另一个存储桶中的文件运行正常(即 images.domain.com/upload67.jpg
且在上传存储桶中带有upload67.jpg)
Files from the other bucket are working fine (ie images.domain.com/upload67.jpg
with upload67.jpg in the uploads bucket)
推荐答案
模式/products/*
匹配指定来源存储桶中名为产品"的文件夹中的所有对象.因此,密钥必须为 products/78/34.jpg
.
The pattern /products/*
matches all objects in the specified origin bucket that are in a folder called 'products'. So, the key needs to be products/78/34.jpg
.
如果您在产品存储桶中创建一个名为产品"的文件夹并将73/34.jpg文件移入其中,则 images.domain.com/products/78/34.jpg
网址应该可以正常工作(如果您最近在创建文件夹之前遇到错误,则可能需要使其无效).
If you create a folder called 'products' inside the products bucket and move the 73/34.jpg file in to it, the images.domain.com/products/78/34.jpg
url should then work (you might need to invalidate if you recently got a error before creating the folder).
这篇关于同一CloudFront分布中的多个S3存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!