Sreejith
Sreejith

Reputation: 67

Can I Use same AWS S3 bucket for 2 domains whilst using the cloudflare CDN

I am using AWS S3 bucket for storing and displaying the user upload image files. My website name is example.net and as I want to use cloudflare CDN and show the image url path as images.example.net (as I want to mask the S3 url). I created a S3 bucket with name images.example.net and mapped the CNAME images.example.net.s3.us-east-1.amazonaws.com as images.

So I am able to access the images using url images.example.net/myPic.jpg Recently I got a new domain example.com (only the extension is different), and now I want to use the same S3 bucket example.net to store the files and the url needs to shown as images.example.com/myPic.jpg

If I create a new S3 bucket images.example.com , then I can do it, but I want to use the existing one only.

Is there any method to configure in cloudflare for that ? Can I do it without creating a new bucket named images.example.com ?

Upvotes: 1

Views: 706

Answers (1)

Chris Williams
Chris Williams

Reputation: 35146

If you're using virtual hosting then you're limited to a single domain per bucket by using the domain as the bucket name.

The only options available to you are:

  • Create a second S3 bucket with your other domain name as the CNAME
  • Create a CloudFront distribution in front of your S3 bucket and specify both domains as alternative domain names. Then on CloudFlare use the CloudFront CNAME. Disable all caching to allow CloudFlare to handle all the CDN functionality.

Obviously neither are ideal for your scenario, however these are the options available at this time.

Upvotes: 2

Related Questions