Hosting on S3 via Google Domains and Cloudflare
I recently decided to move all my personal projects over to AWS. I wanted to host chander.app on S3 — but keep the domain on Google Domains as much as possible. To minimize domain churn, I like to employ subdomains.
chander.app
| cs1.chander.app
| cs50.chander.app
| h3.chander.app
| boardgames.chander.app
| ...
This not only saves me money but also allows me to just start coding immediately. Often, I paralyze myself looking through domain registrars as I dream up the name with the highest potential for virality.
Almost all of my side projects are hosted on Github Pages, which is configured easily enough with an additional CNAME. The problem, of course, comes with the root domains. S3 doesn’t expose a static IP address, and the DNS standard doesn’t allow CNAMEs for root records.
So what do we do?
One option is to create a www
subdomain, and simply reroute all requests there instead. But that felt too 90’s web for me.
The folk at Cloudflare however support root-level CNAME domain flattening!
So we can get the desired set up working in three steps:
- Switch the nameservers on google domains to Cloudflare
2. In order to get https working, make sure to set the Cloudflare setting to SSL settings to Flexible
3. To support the other Github Pages subdomains, remember to turn off the proxy on Cloudflare — those should be DNS only.
Note — if you want to use stricter TLS security, you’ll have to use Amazon’s own Cloudflare offering, but this will be more expensive.