How to disable access to an Amazon S3 endpoint access point

Let's say you want to host a static website on S3:

  • Create a bucket with a name your-website.com

    and set it up for your web host;
  • You add CNAME to your domain domain file to point to your S3 bucket.

Great. Everything works fine when you visit your-website.com

. But you don't want the origin / bare endpoint to be available.

Is there any setting in the bucket to disable direct access to your-website.com.s3-website.your-region.amazonaws.com

?

The reason is that if your website is accessible both through your-website.com it your-website.com.s3-website.your-region.amazonaws.com

could hurt your SEO (duplicate content)

+3


source to share


1 answer


You mentioned your main SEO concern. You can use other methods for this purpose, which are probably easier to implement than the one you originally asked about.

One of the main techniques for handling duplicate content is to use rel=canonical

, which is probably fairly easy to implement. For more information see http://googlewebmastercentral.blogspot.com.br/2013/04/5-common-mistakes-with-relcanonical.html

If you insist on the need to disable bucket access if the client is not connecting through your CNAME, your best bet is to use CloudFront. You will disable the S3 website hosting option in your bucket, make your S3 slave a bucket (i.e. remove bucket policies or ACLs to allow public read), create a CloudFront distribution, define your bucket as a source, set up CNAME in your distribution. change your DNS records to point to your distribution instead of a bucket, create an Identity Access Identity (OAI) in your distribution, and give your bucket access to that OAI. Uf.



This way the user doesn't have access to the contents of your S3 bucket (unless they have AK / SK with read bucket permissions and explicitly send a signed request). The only way is through your domain.

For details on Identity Identity Access see http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html

+3


source







All Articles