A few times now I’ve run into a situation where I want a site hosted in AWS (amazon web services) and I also want the site to be HA (highly available). The best way to achieve this is to have multiple web servers behind an ELB (elastic load balancer). I’m sure you’ve done the same thing many times too.
Now this can lead to a problem. What if I want my website to be accessible via the address http://mysite.tld ?
Normally this is easy to solve and you would just point the DNS for the @/root record of mysite.tld to an IP address. However ELB’s when scale have a habit of changing IP address when they scale, and you can’t currently attach an Elastic IP to them. Amazon tell you to get round this problem you should use a CNAME in your DNS.
Here lies the problem!
If you are using a subdomain such as http://www.mysite.tld you are fine using a CNAME, but the @/root record call it what you will does not allow you to use a CNAME for it. This by design and is in the RFC for DNS, you can only use an IP address.
So you either take the risk that your ELB wont scale or you end up stuck not being able to access your site via http://mysite.tld.
However! You can now point your @/root domain to a service hosted here on SquareCows that simply rewrites your @/root domain mysite.tld and issues a SEO friendly 301 redirect and sends the user to http://www.mysite.tld. This means you can CNAME your www record to the ELB address but still allow traffic to hit the root domain of your site.
You can use this service hosted by SquareCows by pointing your @/root DNS record to: 188.8.131.52
We’ve tested this service to a very high level and the current version that’s running on our servers can manage 1 million requests a min over the HA servers, but we have a new version to deploy that should be better by a factor of 4!
Alternatively if you have a static IP and wish to run this service yourself head over to git hub and fork the project. Its also open source and licensed under the AGPL v3:
Its written in nodeJS and uses the cluster functions to take advantage of multiple cores. Feel free to commit pull requests!