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
+7.2k Golang : How to iterate a slice without using for loop?
+7.2k Golang : Not able to grep log.Println() output
+13.3k Golang : error parsing regexp: invalid or unsupported Perl syntax
+13.9k Golang : convert rune to unicode hexadecimal value and back to rune character
+12.6k Android Studio : Highlight ImageButton when pressed on example
+5.6k Unix/Linux/MacOSx : Get local IP address
+17k Golang : Covert map/slice/array to JSON or XML format
+9.4k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+12.9k Swift : Convert (cast) Int to String ?
+7.2k Golang : Check if one string(rune) is permutation of another string(rune)
+18.9k Golang : Read input from console line
+5.1k Python : Create Whois client or function example