【问题标题】:How to allow aws s3 bucket contents only to publicly serve a certain domain?如何只允许 aws s3 存储桶内容公开服务于某个域?
【发布时间】:2012-02-16 15:13:57
【问题描述】:

我正在使用 aws s3 来存储我的网站图片和视频内容。来自s3的文件链接直接输出到html/php。

问题是其他一些网站链接了我的图片/视频,这大大增加了 s3 流量的使用,当然也增加了支付费用。

我知道在某些情况下人们会使用引用标头来禁止外部网站链接。但在这种情况下,图片/视频直接从 s3 输出,而不是我的域。

有人可以帮助实现这一目标吗?谢谢。

【问题讨论】:

标签: amazon-s3 amazon-web-services


【解决方案1】:

您可以使用 Amazon 存储桶策略,例如:

{
    "Version": "2012-10-17",
    "Id": "http referer policy example",
    "Statement": [
        {
            "Sid": "Allow get requests originated 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/*"
                    ]
                }
            }
        }
    ]
}

详细解释在:http://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html

【讨论】:

  • 请您添加更多细节,完善它以回答确切的问题。干杯
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-11-10
  • 2020-11-09
  • 2018-05-21
  • 1970-01-01
  • 2021-10-09
  • 2018-12-05
  • 1970-01-01
相关资源
最近更新 更多