Amazon S3 – How to Fix Static Site Using Wrong Bucket

amazon s3domain-name-systemstatic-files

I'm setting up a static site, hosted on S3, using this set of directions:
https://www.linode.com/docs/platform/object-storage/host-static-site-object-storage/

I've set my bucket up with the name holisticnetworking.net-static. I walked through the process of setting up the bucket to serve over HTTPS and checking the info, it seems to work fine:

tomb@MacBook-Pro-3 ~ % s3cmd ws-info s3://holisticnetworking.net-static
Bucket s3://holisticnetworking.net-static/: Website configuration
Website endpoint: http://holisticnetworking.net-static.s3-website-us-east-1.amazonaws.com/
Index document:   index.html
Error document:   404.html

You can also browse to the bucket endpoint and that works fine, too:
http://holisticnetworking.net-static.s3-website-us-east-1.amazonaws.com/

The strange problem I find at the end of that journey is that when I browse to the site I get the following error message:

Code: NoSuchWebsiteConfiguration
Message: The specified bucket does not have a website configuration
BucketName: holisticnetworking.net
RequestId: xxx
HostId:xxx

Note that, for some strange reason, the bucket the error appears to point to is another one called holisticnetworking.net. Not the -static bucket.

Does anyone have any idea what is happening, here?

Best Answer

A custom domain name must match the bucket name.

Amazon S3 sees only the original hostname www.example.com and is unaware of the CNAME mapping used to resolve the request. So the CNAME and the bucket name must be the same.

https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html

To disconnect the hostname of your site from the actual name of the bucket requires that you use CloudFront in addition to S3, pointing your DNS record to CloudFront and pointing CloudFront to the bucket.

I walked through the process of setting up the bucket to serve over HTTPS

It's not clear what you mean by that. You can't use HTTPS on a custom domain with an S3 bucket without also using CloudFront.

The Amazon S3 website endpoints do not support HTTPS.

https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html

See https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-https-requests-s3/

Related Topic