问题
I have several subdomains that will have their own S3 bucket. Is there a way to set S3 bucket to allow GET requests only from a specific subdomain?
回答1:
Use an aws:Referer condition. From Restricting Access to a Specific HTTP Referrer:
{
"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/*"]}
}
}
]
}
来源:https://stackoverflow.com/questions/32453602/can-i-restrict-access-to-s3-from-a-specific-subdomain-only