2016-04-02 59 views
0

有沒有辦法允許存儲在我的aws s3中的靜態圖像只能在我的域xyz.com下訪問?允許來自S3的圖像僅在我的域名下

我所知道的,不固定的圖像,我只是想避免人們通過

感謝

+0

http://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use- case-4 –

+0

我想吻你,謝謝 – RollRoll

回答

0

粘貼S3 URL在新的瀏覽器選項卡,在提及Mark B查看圖像評論,可以創建Amazon S3存儲桶策略。

當中許多可能的策略設置是Referrer選項:

假設你有一個域名(www.example.comexample.com)網站鏈接到存儲在S3存儲桶,examplebucket的照片和視頻。默認情況下,所有S3資源都是私有的,因此只有創建資源的AWS賬戶才能訪問它們。爲了允許從您的網站對這些對象進行讀取訪問,您可以使用aws:referer密鑰添加一個存儲桶策略,該存儲桶策略允許s3:GetObject條件的權限,即獲取請求必須源自特定的網頁。以下策略使用aws:Referer條件密鑰指定StringLike條件。

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

查看文檔:Restricting Access to a Specific HTTP Referrer