Hosting a naked (no-www) domain on dotcloud, GAE, etc.

Some platform-as-a-service providers like Google App Engine, dotCloud, etc. don't allow you to host a naked domain (example.com), and only serve requests from the www subdomain (www.example.com).

However, there is a neat hosted service called wwwizer which will redirect your no-www domain to your www domain, for free.

Here are my steps for hosting a naked domain with wwwizer on dotCloud. I also threw Cloudflare into the mix because they have a nice interface for editing DNS records and some other cool features (CDN, DoS protection, etc.). Using Cloudflare is not required for wwwizer to work.

  1. Add the domain to Cloudflare
  2. Cloudflare will copy your existing DNS records
  3. Cloudflare will provide you with two new name servers (x.ns.cloudflare.com and y.ns.cloudflare.com). Delete all your existing NS records and replace them with the two Cloudflare name servers.
  4. Wait until the nameservers switch over, you will get a message in the Cloudflare admin area. You can also check an HTTP response from your server, the "Server" HTTP header should say "cloudflare".

To host the site on dotCloud you then make these two changes from within Cloudflare:

  1. Set the A record for example.com (the naked domain) to 174.129.25.170 (wwwizer.com)
  2. Set the A record for www to the IP address of gateway.dotcloud.com

Now your naked domain example.com will redirect to www.example.com, which will be hosted by dotCloud. Step #6 is the only part that is specific to dotCloud, just change this to whatever your PaaS provider tells you to, and you should be all set.

blog comments powered by Disqus
Illustration of a grassy knoll