Problem: Using my CNAME on cloudflare (assets.my-site.com) I am trying to point to a public AWS S3 bucket. If I navigate to the AWS hostname I can clearly see it working in multiple browsers (public read access is correct) however when I try to access via assets.my-site.com (cloudflare CNAME) I get the error
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>assets.my-site.com</BucketName>
Im pretty sure the issue is with this <BucketName>assets.my-site.com</BucketName>
that somehow amazon is picking up assets.my-site.com as the hostname of the bucket instead of the correct S3 target
2
Answers
I believe yes, you need to rewrite host header here, you can do that for example via Cloudflare Page Rules, you need to put your CNAME to the URL (required) field, and name of the bucket to the value, it should looks like:
The other answers and comments have basically answered this, but to answer this clearly your bucket needs to be named
assets.my-site.com
. From the error it’s fairly clearmy-bucket
is a different value thanassets.my-site.com
.I have posted a similar answer that shows how to serve a static bucket using Cloudflare to dramatically reduce bandwidth usage here.