AWS S3 : Prevent Hotlinking policy
Tags : aws s3 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
Tags : aws s3 hotlinking policy
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.1k Golang : bufio.NewReader.ReadLine to read file line by line
+2k Golang : Muxing with Martini example
+7.7k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+6.1k Golang : List objects in AWS S3 bucket
+3k Golang : Get month name from date example
+20.7k Golang : Comparing date or timestamp
+2.6k Golang : Delay or limit HTTP requests example
+2.1k Golang : If else example and common mistake
+4.7k Golang : Setting variable value with ldflags
+1.6k Golang : Extract unicode string from another unicode string example
747 Golang : Accessing dataframe-go element by row, column and name example
+5k Golang : How to reverse elements order in map ?