Amazon web services 我可以在同一个Cloudfront发行版上使用已签名和未签名的URL吗?

Amazon web services 我可以在同一个Cloudfront发行版上使用已签名和未签名的URL吗?,amazon-web-services,amazon-s3,amazon-cloudfront,Amazon Web Services,Amazon S3,Amazon Cloudfront,这个标题或多或少说明了这一切。从Cloudfront管理控制台(下图)的“限制观众访问”部分使用单选按钮这一事实来看,这似乎是一种非此即彼的情况 问题:是否有其他方法来解析一个人的S3存储桶,使其可以同时包含公共(即任何人都可以查看)和私有(即签名URL)内容?我可以回答我自己的问题。是的,您可以在同一Cloudfront发行版中拥有已签名和未签名的URL。在下面的示例中,我的发行版名为blahblah.cloudfront.com。关键是指定两个“源服务器”。一个用于已签名的URL,另一个用于

这个标题或多或少说明了这一切。从Cloudfront管理控制台(下图)的“限制观众访问”部分使用单选按钮这一事实来看,这似乎是一种非此即彼的情况


问题:是否有其他方法来解析一个人的S3存储桶,使其可以同时包含公共(即任何人都可以查看)和私有(即签名URL)内容?

我可以回答我自己的问题。是的,您可以在同一Cloudfront发行版中拥有已签名和未签名的URL。在下面的示例中,我的发行版名为
blahblah.cloudfront.com
。关键是指定两个“源服务器”。一个用于已签名的URL,另一个用于未签名的URL

->AWS Management Console->Cloudfront->Distribution settings of selected Distribution

->Origins: create both origins (e.g., pointing to 2 different S3 buckets)

->Behaviors: create "path patterns" for each origin such that Cloudfront can 
distinguish which origin the Cloudfront url points to. E.g., in my S3 bucket named 
"tim-UNsigned-bucket" I set the path pattern to `uploads/*`.  For my signed url bucket, 
I gave it the more general path pattern of `*` and prioritized it 2nd.
As you can see below, this means that my unsigned url includes the path, uploads/, 
whereas my signed does not.
结果Cloudfront url结构:

  • 签名URL:
    https://或http://blahblah.cloudfront.com/file1.jpg?Policy=asf...

  • 未签名的URL:
    https://或http://blahblah.cloudfront.com/uploads/file2.jpg


注意:进行这些更改可能需要Cloudfront几分钟(5-15分钟)才能更新。因此,请尽你所能,以尽可能少的错误来改变我的方向,否则,这将花费你一辈子的时间

坏消息是你需要两种不同的行为。似乎没有一种好的方法可以通过CloudFront按每个资源要求一个签名URL。这意味着除了物理移动资源外,没有其他方法可以在公共和私有资源之间“切换”资源。