Wow. First off, Amazon Web Services just got really cheap. Cheap as in free – most of the time. I won’t go into detail, because, well, this is the web after all and details are so very fluid, but you should check it out.
So, I set up a static site (for now, anyway) on S3 (Simple Storage Service – I didn’t know that until recently) and a virtual machine in EC2 (Elastic Compute Cloud – didn’t know that one, either). I have a domain through Network Solutions, and I couldn’t for the life of me figure out how to point a naked domain, e.g. http://thomasqbrady.com – without the www subdomain, to the S3 instance without domain-masking.
Domain-masking, if you didn’t know, is a fancy product name that Network Solutions uses (I think the term has real meaning in other uses) for a frameset on your page. The top frame is a page on Network Solutions’ server somewhere with a fixed IP. The bottom frame is your site, wherever that might actually be hosted. That way you get an A record DNS name (their fixed-IP server) with your domain name, but you get to point wherever you like. Normally, you have to have an IP address for an A record. Amazon’s EC2 and S3 only give you DNS names (URLs), unless you pay extra.
You can set up on Network Solutions a domain forward (which will imediately redirect your users to your actual URL) instead of a domain mask, but then your users will see your ugly S3/EC2 domain names.
You might be thinking, “Just use a CNAME, dummie!”
CNAMEs are great. I can use a CNAME to point any subdomain to a URL. For instance, I’m pointing projects.thomasqbrady.com to a Redmine instance on the EC2 server. I’m also pointing http://www.thomasqbrady.com to the S3 instance that way. If I didn’t care about the naked domain (and, realistically, it’s not that big a deal), then I could just be done with that. CNAMEs to the rescue.
But I would lose sleep over the stupid naked domain issue.
So here’s how I did it
It took me hours of tinkering to think of this. Many of you might have known right away. But I never saw this documented anywhere or found anyone else saying this worked. But it’s currently working for me.
This setup works on Network Solutions. It might work elsewhere, but that’s the only place I’ve tried.
- Setup domain-forwarding, forwarding your top-level domain (thomasqbrady.com in my case) to the www subdomain (www.thomasqbrady.com in my case), but without the domain-masking.
- Wait a bit for this to take effect.
- When it has, edit advanced DNS settings.
- Delete your A records for www and *, but leave your @ record.
- Now create your CNAME records for www to point at your S3 instance.
- You’re now forwarding from the naked domain http://%5BYOUR DOMAIN HERE] to the subdomain http://www.%5BYOUR DOMAIN HERE], which is a CNAME mask for your S3 instance, [BUCKET NAME].s3-website-us-east-1.amazonaws.com