我的设置:
/home/%u
)链接到CloudFront CDN的存储桶我的意图是:考虑一个对象,其原始位置为cdn.mydomain.com
,而CDN位置为mybucket.s3.amazonaws.com/object.jpg
。
仅在以下时间允许
cdn.mydomain.com/object.jpg
)访问的对象
仅使用CDN URL访问而没有标题(即粘贴到浏览器中的链接)的对象
为此,我正在使用以下政策:
mydomain.com
我面临两个问题:
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement":
[
{
"Sid": "Allow access to objects when requested by CloudFront Distribution",
"Effect": "Allow",
"Principal":
{
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity <my ID>"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<my bucket>/*"
},
{
"Sid": "Give access if referer is not set",
"Effect": "Allow",
"Principal": { "AWS": "*" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<my bucket>/*",
"Condition":
{
"StringNotLike":
{
"aws:Referer": "*"
}
}
},
{
"Sid": "Give access if referer is my site",
"Effect": "Allow",
"Principal": { "AWS": "*" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<my bucket>/*",
"Condition":
{
"StringLike":
{
"aws:Referer": ["https://www.example.com/*","https://example.com/*"]
}
}
}
]
}
)仍然可以访问。任何帮助将不胜感激。