CNAME multiple domains to single S3 bucket

Hi,

We would like to CNAME multiple domains to a single AWS S3 bucket to serve images, to do so I followed URL: https://stackoverflow.com/questions/11606086/how-do-i-map-multiple-domains-to-the-same-bucket-on-amazon-s3.

I did the followings:

a. created S3 bucket i.e. mydomain.com
b. stored images in mydomain.com
c. configured CNAME
d. mydomain.com CNAME mydomain.com.s3-website.ap-south-1.amazonaws.com
After performing steps from a - d when we open mydomain.com it shows image content which is absolutely fine.

Now, as mentioned in the stackoverflow [1] (article brief description below)

e. created second bucket XYZ.mydomain.com
f. redirected it mydomain.com
g. created CNAME XYZ.mydomain.com CNAME mydomain.com

After performing steps from e - g, when we open XYZ.mydomain.com it actually redirect to mydomain.com in place of domain name remain same as XYZ.mydomain.com and serve images from mydomain.com

#[1] You can create a second empty S3 bucket for my-domain.com and configure it to redirect to the domain mydomain.com. Then just use the same DNS settings to point both to the Amazon S3 domain for the bucket with all your static HTML files
and redirected.

Could you please advise where we are going wrong…

Thank you,

DS

I’m unsure how this question relates to Cloudflare. Perhaps it would be better to ask about this on the AWS forums?

1 Like

Hi,

AWS suggest some solution to point single S3 bucket to point multiple CNAME refer url below [1], but for this we need to use AWS CloudFront CDN service… however we are looking for similar solution within Cloudflare CDN + DNS service to host images from single bucket to point multiple CNAME domains.

[1] https://www.dreamcode.io/blog/hosting-multiple-sites-with-just-one-s3bucket-lambda-edge

DS