如何使用存储桶策略AWS S3防止图像热链接

时间:2017-04-03 13:04:48

标签: amazon-web-services amazon-s3 bucket hotlinking

我正在尝试阻止我的S3存储桶中的图像热链接。我认为斗牛政策会起作用,但到目前为止还没有运气:

{
    "Version": "2008-10-17",
    "Id": "Bucket policy for example.com",
    "Statement": [
        {
            "Sid": "Allow GET requests referred by example.com",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::example/*",
            "Condition": {
                "StringLike": {
                    "aws:Referer": [
                        "https://www.example.com/*",
                        "http://www.example.com/*",
                        "https://example.com/*",
                        "http://example.com/*"
                    ]
                }
            }
        },
        {
            "Sid": "Allow GET requests that don't specify a referrer",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::example/*",
            "Condition": {
                "Null": {
                    "aws:Referer": true
                }
            }
        }
    ]
}

如何制作此政策以拒绝访问嵌入其他网站的图片?

0 个答案:

没有答案