Search code examples
amazon-web-servicesamazon-s3dnscloudflareamazon-route53

Having trouble creating a subdomain record on CloudFlare that will eventually point to my AWS S3 bucket’s static url


I’m using CloudFlare as a hosting provider for my website, and AWS S3 to serve my static content. From CloudFlare I created a CNAME for my root domain (example.com) that points to my S3 bucket’s static url. This is currently working (see below). enter image description here

However, when I try to set up a subdomain (www.example.com) CNAME record on CloudFlare that points to my root domain (example.com) my website doesn’t render. I’ve also tried pointing the subdomain to the S3 bucket url, but that doesn't work either (because the S3 bucket name has to start with www.example.com, not example.com).

Knowing this ^, I created an S3 bucket that starts with www.example.com and redirected it to the root domain bucket that serves all the content (example.com-bucket). However, this didn’t work either.

Another theory I had was to create an AWS Route 53 hosting zone, so I did that as well (see below). However, none of the records I created in Route 53 made any impact. enter image description here

If anyone has any suggestions it would be greatly appreciated! I’ve looked at various documentation from AWS, CloudFlare, and StackOverflow, but nothing seems to help


Solution

  • A much simpler solution, that doesn't require creating extra S3 buckets and redirect rules in S3, is to create a page rule in Cloudflare that forwards/redirects www to the root domain