gpt4 book ai didi

amazon-s3 - 限制访问 S3 上托管的网站

转载 作者:行者123 更新时间:2023-12-03 01:39:33 26 4
gpt4 key购买 nike

我想在亚马逊 S3 上托管一个静态网站,但我需要限制某些用户对其的访问。这可能是通过 IP 地址或亚马逊凭证(只有登录的用户才能访问存储桶的内容。

这可能吗?

谢谢

最佳答案

是的,这确实是可能的。对您来说更好的起点是 S3 access control

但默认情况下,在 S3 上创建的存储桶不是公开的。因此,默认行为应该是只有知道您的访问权限和 key 的人/程序才能访问它。

您还可以edit bucket permission以便授予对特定 AWS 账户或电子邮件 ID 的访问权限。

为了限制对某些 IP 的访问,您可以创建额外的存储桶策略。

限制对特定 IP 地址的访问

This statement grants permissions to any user to perform any S3 action on objects in the specified bucket. However, the request must originate from the range of IP addresses specified in the condition. The condition in this statement identifies 192.168.143.* range of allowed IP addresses with one exception, 192.168.143.188.

Note that the IPAddress and NotIpAddress values specified in the condition uses CIDR notation described in RFC 2632. For more information, go to http://www.rfc-editor.org/rfc/rfc4632.txt.

{
"Version": "2012-10-17",
"Id": "S3PolicyId1",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::bucket/*",
"Condition" : {
"IpAddress" : {
"aws:SourceIp": "192.168.143.0/24"
},
"NotIpAddress" : {
"aws:SourceIp": "192.168.143.188/32"
}
}
}
]
}

有关更多信息,请阅读 herehere .

关于amazon-s3 - 限制访问 S3 上托管的网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14278698/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com