Skip to content

Instantly share code, notes, and snippets.

@elasticdog
Last active December 11, 2015 21:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elasticdog/4660155 to your computer and use it in GitHub Desktop.
Save elasticdog/4660155 to your computer and use it in GitHub Desktop.
AWS S3 Bucket Policy to Deny Hotlinking Images
{
"Version": "2008-10-17",
"Id": "http referer policy",
"Statement": [
{
"Sid": "Allow GET requests",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::elasticdog.com/*"
},
{
"Sid": "Deny hotlinking images",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::elasticdog.com/images/*",
"Condition": {
"StringNotLike": {
"aws:Referer": [
"http://elasticdog.com/*",
"https://elasticdog.com/*",
"http://elasticdog.com.s3-website-us-west-2.amazonaws.com/*",
"https://elasticdog.com.s3-website-us-west-2.amazonaws.com/*"
]
},
"Null": {
"aws:Referer": false
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment