Created
September 13, 2012 18:26
-
-
Save alicial/3716433 to your computer and use it in GitHub Desktop.
Amazon S3 Bucket Policy to prevent hot linking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2008-10-17", | |
"Id": "0c762de8-f56b-488d-a4a4-20d1cb31df2f", | |
"Statement": [ | |
{ | |
"Sid": "Allow in my domains", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "*" | |
}, | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::<Bucket Name>/*", | |
"Condition": { | |
"StringLike": { | |
"aws:Referer": ["http://<allowed referrer site(s)>/*", "http://www.<allowed referrer site(s)>/*"] | |
} | |
} | |
}, | |
{ | |
"Sid": "Give not access if referer is no my sites", | |
"Effect": "Deny", | |
"Principal": { | |
"AWS": "*" | |
}, | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::<Bucket Name>/*", | |
"Condition": { | |
"StringNotLike": { | |
"aws:Referer": ["http://<allowed referrer site(s)>/*", "http://www.<allowed referrer site(s)>/*"] | |
} | |
} | |
} | |
] | |
} |
How about a request from mobile app. I mean just allow a request get image when this request from my app
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow, this is the ONLY policy that I've found that works as it should.. thank you!!