首页 文章

我可以在同一个Cloudfront发行版上使用已签名和未签名的网址吗?

提问于
浏览
8

Headers 或多或少都说明了一切 . 从Cloudfront管理控制台的"restrict viewer access"部分(下图)使用单选按钮这一事实来看,它似乎是一种情况 .
cloudfront console

QUESTION: 是否有其他方法可以解析一个人的S3存储桶,使其既可以公开(即可以被任何人查看),也可以拥有私有(即签名网址)内容?

1 回答

  • 7

    我可以回答我自己的问题 . 是的,您可以在同一个Cloudfront发行版中拥有已签名和未签名的URL . 在下面的示例中,我的发行版称为 blahblah.cloudfront.com . 关键是要指定两个"origin server" . 一个用于签名的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.
    

    Resulting Cloudfront url structure:

    • 签名网址: https:// or http://blahblah.cloudfront.com/file1.jpg?Policy=asf...

    • 未签名的网址: https:// or http://blahblah.cloudfront.com/uploads/file2.jpg

    Note: 进行任何这些更改都需要几分钟(5-15分钟)进行更新 . 因此,尽可能以最少的错误尽可能地在我的方向上做出所有改变,否则它将永远带你 .

相关问题