amazon-web-services - 我可以在同一个 Cloudfront 发行版上使用签名和未签名的 url 吗?

标签 amazon-web-services amazon-s3 amazon-cloudfront

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

问题:是否有其他方法可以解析一个 S3 存储桶,以便它可以同时包含公共(public)(即任何人都可以查看)和私有(private)(即签名的 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 结构:
  • 签名网址:https:// or http://blahblah.cloudfront.com/file1.jpg?Policy=asf...
  • 未签名的网址:https:// or http://blahblah.cloudfront.com/uploads/file2.jpg

  • 注:进行任何这些更改都可能需要 Cloudfront 几分钟(5-15 分钟)来更新。因此,尽最大努力以尽可能少的错误对我的方向进行所有更改,否则它将永远带你走。

    关于amazon-web-services - 我可以在同一个 Cloudfront 发行版上使用签名和未签名的 url 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18906831/

    相关文章:

    java - Play Framework 2.2 Java Iteratee - 响应式上传

    amazon-s3 - 如何使用 AWS CDK(首选 typescript)向 API 网关的现有 AWS cloudfront 发行版添加行为?

    amazon-web-services - 带有 Kinesis Event Consumer 的 AWS CloudFormation 模板

    sql - 如何更改存储在 S3 中的 Athena 结果的名称?

    amazon-web-services - 将 AWS Lake Formation 与 CloudFormation 结合使用

    amazon-web-services - 将 CloudFront 分配与 Route 53 域相关联时出现问题

    php - Amazon Cloudfront 私有(private)分发 - CSS 内图像的链接

    java - 使用变量的值作为枚举值

    node.js - Amazon CloudFront 能否接受 KMS 加密的 URL?

    php - 无法将文件上传到主存储桶的子文件夹