How to Prevent Hotlinks on Amazon S3 Bucket

December 6, 2023 | By the+gnu+linux+evangelist.

Amazon S3 Bucket Preventing Hotlinks Guide

Hi! The Tutorial shows you Step-by-step How to Block Hotlinks on an Amazon S3 Bucket.

And to Fix this possible Issue you have to Set a Bucket Policy.

With Amazon S3 Bucket Policies, you can secure access to Objects in your Buckets, so that only users with the appropriate permissions can access them.

You can even prevent authenticated Users without the appropriate permissions from accessing your Amazon S3 resources.

Featured
  1. Login in the Amazon AWS Console
    Select Amazon S3 from Drop Down list Click “Sign in the AWS Console”
    Insert your Credentials
  2. Amazon S3 > Properties > Edit Bucket policy
    Insert: (Substitute only YOUR-BUCKET-NAME and your-domain-name)

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

    Last, Save and then Test it!


QuickChic Theme • Powered by WordPress