2012-02-16 89 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

相關問題