AWS S3 : Prevent Hotlinking policy
Problem :
Hosting a lot of photos or video files on AWS S3? Don't want other websites to link to your content or use your S3 as a free loader?
Solution :
Add new bucket policy to prevent hot linking. Go to the properties of the S3 bucket you want to prevent hot linking policy and click on the Add Bucket Policy button.
A modal box will appear and enter this policy :
{
"Version": "2008-10-17",
"Id": "preventHotLinking",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-s3-bucket/*",
"Condition": {
"StringLike": {
"aws:Referer": [
"http://yourwebsitename.com/*",
"http://www.yourwebsitename.com/*"
]
}
}
}
]
}
NOTE : Change your-s3-bucket and yourwebsitename.com to yours.
Reference :
https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html
See also : WARNING: UNPROTECTED PRIVATE KEY FILE! error message
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+10.4k Golang : Generate random integer or float number
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+29.5k Golang : Login(Authenticate) with Facebook example
+7.9k Golang : How to feed or take banana with Gorilla Web Toolkit Session package
+8.6k Golang : Convert(cast) []byte to io.Reader type
+19.3k Golang : Get RGBA values of each image pixel
+16.1k Golang : How to reverse elements order in map ?
+10.5k Swift : Convert (cast) String to Integer
+23k Golang : Calculate time different
+6.9k Mac/Linux/Windows : Get CPU information from command line
+7.9k Golang : Get today's weekday name and calculate target day distance example
+11.5k Golang : Change date format to yyyy-mm-dd