M. *_*lis 5 json amazon-s3 amazon-web-services
我尝试使用privatewebsite.com存储桶策略将对 Amazon S3 存储桶中的对象(媒体文件)的访问限制为特定的引用域 ,但无论引用的域如何,访问都会被拒绝。
我对阻止公共访问有以下设置
阻止对通过新访问控制列表 (ACL) 授予的存储桶和对象的公共访问 - 开
阻止对通过任何访问控制列表 (ACL) 授予的存储桶和对象的公共访问 - 开
阻止对通过新公共存储桶策略授予的存储桶和对象的公共访问 - 关闭
通过任何公共存储桶策略阻止对存储桶和对象的公共和跨账户访问 - 关闭
我添加了以下代码,包含和不包含 http:// 和 https:// 的 URL,但访问仍然被拒绝。(privatewebsite.com、https://privatewebsite.com、http : //privatewebsite.com)
{
"Version": "2012-10-17",
"Id": "Policy8675309",
"Statement": [
{
"Sid": "Stmt8675309",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-media-bucket/*",
"Condition": {
"StringLike": {
"aws:Referer": "https://privatewebsite.com"
}
}
},
{
"Sid": "Explicit deny to ensure requests are allowed only from specific referer.",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-media-bucket/*",
"Condition": {
"StringNotLike": {
"aws:Referer": [
"https://privatewebsite.com/*",
"http://privatewebsite.com/*"
]
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以看到我的存储桶策略中存在任何明显错误吗?
我希望此策略允许来自 privatewebsite.com 页面的任何请求,同时拒绝所有其他请求,但目前所有请求都被拒绝。
来自存储桶策略示例 - 限制对特定 HTTP Referrer 的访问:
{
"Version": "2012-10-17",
"Id": "http referer policy example",
"Statement": [
{
"Sid": "Allow get requests originating from www.example.com and example.com.",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::examplebucket/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://www.example.com/*",
"http://example.com/*"
]
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
此方法仅授予Allow给定 Referer 的访问权限。无需对其使用Deny策略,因为默认情况下会拒绝访问。因此,仅Allow授予权限。
| 归档时间: |
|
| 查看次数: |
4172 次 |
| 最近记录: |