today   10 Oct 2017

access_time  2 minutes to read

Getting on S3

There was a little bit of a self inflicted hurdle getting this site hosted on S3. But first, how this issue came to be.

The Beginning

The domain oeQuacki is actually from my very first serious web project, a forum with a html5 drawing program commonly referred to as oekaki. For this I’ve setup a gmail account which uses the actual @oequacki.com suffix. This means I had to have some stuff in my DNS for Google to know who I am.

When I began thinking about Jekyll, one of the features that stuck out to me was how simple hosting was. Everything I read basically said you can slap it on S3 and it’s done.

What I didn’t realise is that to do so, you can’t just CNAME your root domain, you’re expected to use Amazon’s Route53. Some providers apparently have an ANAME option which you can safely use on your root domain, but VentraIP did not have this option.

The Real Problem

I’m lazy, I want all of my DNS records and their configuration in one place, and I certainly didn’t feel like moving all of them to Amazon’s Route53.

My “Solution”

You may have noticed I’ve only talked about CNAMEing the root domain, if you’re a clever person you’ll probably have noted that this blog isn’t hosted on the root domain, it’s hosted on www.oequacki.com. This is because you can easily CNAME a subdomain. Now, people aren’t really going to ever type www because it’s just not what people do anymore. This means I needed a way to to flick them across to the www subdomain.

I had a bit of a look around but could not really find any information that I liked the look of. One guy suggested just hosting a simple HTML file with an iframe in it, I thought that was way too inelegant for a blog by a web developer.

But, it did give me the idea of just having a 301 permanent redirect on a server with nginx I was already running. I mean, the main goal of this was to be able to shut down another of my rails instances that was barely used but consuming ~100MB of RAM. I consider 4 more lines of config on another server a win.

So, I touched /etc/nginx/sites-enabled/oequacki.conf and put in the following 4 lines:

server {
  server_name  oequacki.com;
  return       301 http://www.oequacki.com$request_uri;
}

A casual /etc/init.d/nginx restart and I was done!

While this may not be the best solution, I’m pretty happy with it. It should be more than stable enough and is much less of a pain to deal with than my home made blog solution.