【发布时间】:2015-07-16 21:08:27
【问题描述】:
我查看了以下答案,但它讨论了私有内容和签名 URL 的原始访问身份。我的内容不是私人的,它对公众开放,但我不希望其他网站热链接到我的图像。换句话说,我网站上的图片应该可以通过我的域下的 URL 访问。
Simple example to restrict access to Cloudfront(S3) files from some users but not others
我已按照以下文档在我的 CloudFront 分配上创建 OAI。
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
在我的发行版上应用 OAI 后,发生了一些奇怪的事情。我可以访问一些图像,而有些则不能。
从 localhost 工作时,我无法访问 CloudFront 图像。
有没有一种方法可以指定哪些域可以访问我的资源而哪些不能?像这样?
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://example.com/*",
"localhost:*"
]
}
}
}
【问题讨论】:
标签: amazon-web-services amazon-s3 amazon-cloudfront hotlinking