2012-02-16 94 views
4

我使用aws s3来存储我的网站图片和视频内容。来自s3的文件链接直接输出到html/php。如何仅允许aws s3存储桶内容公开提供某个域名?

问题是,其他一些网站链接了我的照片/视频,这大大增加了s3流量的使用,并且当然增加了工资单。

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

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

+1

参见:http://stackoverflow.com/questions/3499049/preventing-amazon-s3-带宽窃取 – 2012-02-16 15:35:03

+0

非常感谢。这正是我想要的。我做了搜索,但没有得到这一个。 – Qishan 2012-02-16 15:45:02

回答

3

您可以使用像亚马逊桶政策:

{ 
    "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

+0

请你可以添加更多的细节,提炼它来回答**确切的问题。**干杯 – 2014-10-15 12:58:36

相关问题