我有公共S3存储桶。我想以禁用目录列表的方式配置它。以下配置:
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::_my_bucket_/*"
},
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::_my_bucket_"
}
]
}
具有这样的行为:
curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/<not_existing_object>
回答404,很好curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/<existing_object>
回答200,很好curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/
响应200,并打印我的存储桶中的每个对象,坏 如果我删除s3:ListBucket
,则将有效地禁用“目录列表”,但会破坏404(如AWS docs中所述)。
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::_my_bucket_/*"
}
]
}
它的行为是这样的:
curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/<not_existing_object>
回复403,坏 curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/<existing_object>
回答200,很好curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/
响应200,并打印出我的存储桶中的每个对象,很好是否可以配置s3(无需使用CloudFront(我也不确定是否可以使用CF)),使其具有以下功能:
curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/<not_existing_object>
响应404 curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/<existing_object>
回复200 curl -I https://_my_bucket_.s3.eu-central-1.amazonaws.com/
响应200,并打印出我的存储桶中的每个对象答案 0 :(得分:0)
仅当存在Listbucket权限时,S3才会提供404。我在考虑使用CloudFront的一种解决方案。
curl -I https://d123xxxxx.cloudfront.net/->获取默认的根文档,而不是列出S3的所有对象。
curl -I https://https://d123xxxxx.cloudfront.net/not_existing_object->您仍然会得到404。