Mobile app version of vmapp.org
Login or Join
Speyer207

: Prevent image hotlinking from Amazon S3 and while allowing social networks I'm using Amazon S3 to host some assets (mostly images) on a small project. I'm trying to find a way to prevent leeching

@Speyer207

Posted in: #AmazonS3 #Hotlinking #Images #WebCrawlers

I'm using Amazon S3 to host some assets (mostly images) on a small project. I'm trying to find a way to prevent leeching (which can be very serious should someone tried to use a network of bots to shoot my bill to the stars).

My current approach is using this policy:

{
"Version": "2008-10-17",
"Id": "",
"Statement": [
{
"Sid": "Allow in my domains",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://www.myproject.com/*"
]
}
}
},
{
"Sid": "Deny access if referer is not my sites",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET/*",
"Condition": {
"StringNotLike": {
"aws:Referer": [
"http://www.myproject.com/*"
]
}
}
}
]
}


The issue is that by applying such policy, social network sharing services as Facebook's and Google Plus' becomes unable to reach my images to compose the 'post'. Both Facebook and Google reach for the shared content and transfer a generated thumbnail from the content image to their own servers (Facebook uses Akamai, tbw)...

Does any of you have an idea of which hosts those two social networks uses to retrieve files so I can grant them access?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Speyer207

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

Facebook uses the facebookexternalhit user agent

facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"


Google+ uses a user agent containing "Google"

Google (+https://developers.google.com/+/web/snippet/)


You should grant them access by user agent.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme