Background

我试图明确拒绝对我的S3桶中的资产的GET请求,除非引用者是托管它们的实际站点 . 其中许多资产都是缓存图像,这些图像是Liip Imagine捆绑过滤器(以及这些缓存项目源自的原始上载图像)的结果 .

Problem

当我在我的存储桶中添加显式拒绝语句对这些图像的策略请求时,返回403,这很好,并且许多非缓存图像将加载到正确域下的网站中,但尝试使用Imagine包解析缓存图像结果是404 .

My Bucket Policy

(出于隐私原因,域和桶被遮挡)

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": "arn:aws:s3:::[MY_BUCKET]/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": "https://[MY_DOMAIN]/*"
                }
            }
        },
        {
            "Sid": "ExplicitDenyReferer",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::[MY_BUCKET]/*",
            "Condition": {
                "StringNotLike": {"aws:Referer": "https://[MY_DOMAIN]/*"}
            }
        }
    ]
}

I've built this policy based on information here:

http://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use-case-4

查看检查员,我可以看到有这样的媒体解析请求:

在请求标头中:

  • authority: [MY_DOMAIN]

  • method: GET

  • path: /media/cache/resolve/logo/main-logo.png

  • scheme: https

  • referer: https://[MY_DOMAIN]/

一旦我删除了Bucket策略中的Explicit Deny语句,这些图像就可以正常加载 . 我很困惑为什么404.我可能期望403在某种程度上错误配置,但404是出乎意料的 .

我已经验证了请求标头中的referrer与Deny语句中输入的完全相同 .

Ultimately my questions are:

  • 为什么这个Deny语句会导致404这些媒体解析请求?

  • 如何使Imagine Bundle可以从过滤器配置创建缓存图像,但拒绝对不包含正确引用的图像的请求?