[By Nic Lindh on Sunday, 08 March 2015]
This took me way too long to figure out, so I hope this post will save you some time.
If you’re the kind of cool cat who uses a static site generator like Jekyll for your site you’re probably also the kind of cool person who wants to put your static site on Amazon’s S3 so you don’t have to worry about a traffic spike taking your site down or your site getting hacked.
But if you’re like me you also want the site to use the apex domain, a.k.a. root domain, a.k.a. naked domain, that is, the site itself like thecoredump.org instead of www.thecoredump.org.
Cough hipster cough.
For technical reasons based in the history of the DNS system and how S3 (and platforms like Heroku) works, this is surprisingly difficult.
Amazon, not being idiots, have solved this problem with their Route 53 DNS service. But what if you don’t want to use Route 53?
It looks grim, since Route 53 have figured out what is essentially a hack of the DNS system and one that’s mostly of use to them. Why would anybody else support this?
From a technical standpoint the issue is that the domain name system expects the naked domain, or if you want to use the technical term, the apex domain (which sounds like a pretty cool band name) to be set up to resolve to an IP address but Amazon’s S3 (and Heroku) does its own domain name resolution so there is no IP address to resolve to.
Bother.
But more and more domain name hosts are figuring out how to replicate this feat, and the one I recommend is Cloudflare. If you put your domain behind Cloudflare (which I’ve been doing for years for the Content Delivery Network functionality and the hack protection they provide), they support what they call CNAME flattening, which means they support naked domains for things like Amazon S3 and Heroku. Which is awesome. And free.
Incidentally, as I said, I’ve used Cloudflare for years and am continually amazed that their base level service is free. Seriously? A free CDN? That’s very cool but kind of nutty.
So why not just use Route 53? This goes into a much bigger post about Amazon Web Services. A lot of companies are building their businesses on top of AWS and are very happy with it, but the thing with AWS is that it’s incredibly flexible and that flexibility inevitably leads to complexity. AWS has a massive learning curve.
S3 is sort of an outlier in the AWS eco system in that it’s very straightforward: You create a bucket, you put files in the bucket, people can see the files. Boom. Simple. The rest of the AWS system is very much not so simple, including Route 53.
Route 53 lets you do all kinds of very cool things with the DNS system, but if all you want to do is put up a simple static site for your business you’ll get a headache real quick.
Cloudflare keeps it simple.
It’s so great you can put your static site on S3 and have an apex domain point to it and not have to worry about any kind of server maintenance and upkeep. It’s very future.