我在存儲在S3存儲桶中的站點資產(即圖像,視頻)後面有一個PHP + Symfony Web應用程序,位於Varnish後面。我想通過引薦來源使用s3存儲桶政策來限制對這些資產的訪問。我申請桶的政策是(與識別信息刪除):S3按域返回的桶策略403在Symfony應用中禁用對象請求並使用Varnish
{
"Version": "2012-10-17",
"Id": "http referrer policy example",
"Statement": [
{
"Sid": "Allow get & put requests referred by test.com.",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::mybucket/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"https://www.test.com/*",
"https://test.com/*"
]
}
}
},
{
"Sid": "Explicit deny to ensure requests are allowed only from specific referrer.",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::mybucket/*",
"Condition": {
"StringNotLike": {
"aws:Referer": [
"https://www.test.com/*",
"https://test.com/*"
]
}
}
}
]
}
我比我對SO多和其他的論壇帖子政策,它似乎是正確的。如果我申請這個政策,我的桶,每個資產請求我的網站上出現與響應狀態403破的任何頁面上禁止:
Request URL:http://mybucket.s3-eu-west-1.amazonaws.com/site-assets/img/film-icon.svg
Request Method:GET
Status Code:403 Forbidden
Remote Address:54.231.131.120:80
Referrer Policy:no-referrer-when-downgrade
如果我刪除它再次工作的政策。因此,該策略正在生效,它只是不允許我自己的域(在此示例代碼中爲test.com)訪問資產,但其存儲桶策略中定義爲「允許」。
如果相關,我的web應用程序將KnpGaufrette用作配置爲使用s3的文件系統,而LiipImagineBundle正在使用它來處理需要的任何圖像處理。我的服務器還在Web服務器前安裝了Varnish 4以提供緩存(我已嘗試清除清漆緩存,在應用策略後重新啓動清漆和Apache)。
如果您可以提供幫助,那就太好了。
跑到類似的問題,也許這將幫助你:https://stackoverflow.com/questions/33963428/sonatamediabundle-s3-aws-the-configured-bucket-my-bucket-does-not-exist/47201223 #47201223 –
@ThomasKekeisen謝謝。當我得到片刻時,我會嘗試一下。 – Forer