Skip to content

Instantly share code, notes, and snippets.

@ndarville
Created June 4, 2013 15:01
Show Gist options
  • Save ndarville/5706592 to your computer and use it in GitHub Desktop.
Save ndarville/5706592 to your computer and use it in GitHub Desktop.
Anti-hotlinking S3 bucket policies for www.modrenman.com.
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "Deny access if referer is not set",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::data.modrenman.com/*",
"Condition": {
"StringNotLike": {
"aws:Referer": "*"
}
}
},
{
"Sid": "Give access if referer is my site",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::data.modrenman.com/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://data.modrenman.com/*",
"http://www.modrenman.com/*",
"http://modrenman.com/*"
]
}
}
}
]
}
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "Deny access if referer is not set",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.modrenman.com/static/*",
"Condition": {
"StringNotLike": {
"aws:Referer": "*"
}
}
},
{
"Sid": "Give access if referer is my site",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.modrenman.com/static/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://www.modrenman.com/*",
"http://modrenman.com/*"
]
}
}
}
]
}
@ndarville
Copy link
Author

Compare viewing an image directly versus viewing it in its article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment