[英]Amazon S3 bucket policy allow access to ONLY specific http
我試圖通過存儲桶策略將對Amazon S3存儲桶中的對象(媒體文件)的訪問限制為特定的引用域privatewebsite.com
,但是無論訪問privatewebsite.com
域, privatewebsite.com
拒絕訪問。
我具有以下阻止公共訪問設置
阻止對通過新訪問控制列表(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/*"
]
}
}
}
]
}
誰能在我的存儲桶策略中看到任何明顯的錯誤?
我希望此策略允許來自privatewebsite.com上某個頁面的任何請求,同時拒絕所有其他請求,但目前所有請求都被拒絕。
為您的字符串狀部分(允許部分)嘗試以下操作:
"StringLike": {
"aws:Referer": [
"https://privatewebsite.com/*",
"http://privatewebsite.com/*"
]
}
{
"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/*"
]
}
}
}
]
}
此方法僅授予給定引薦來源的“ Allow
訪問”權限。 由於默認情況下拒絕訪問,因此無需對其使用Deny
策略。 因此,僅授予“ Allow
權限。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.