It’s all about the user experience. As a user, when I browse to either of the following domains, I should see the same content:
- www.mydomain.com (www, in this case, is a sub-domain)
- mydomain.com (when you refer to a domain w/o a sub-domain, it is generally called the apex or root)
For example, end-users may omit the “www”! Skipping characters saves precious characters and time…
In addition to expecting the same content, it (arguably must) be served using HTTPS. For example, if a request comes in using HTTP, transform it somehow to HTTPS.
This weekend I purchased a domain from GoDaddy for a side project. Initially I setup the domain using GoDaddy DNS to serve a SPA from a Standard Akamai CDN using Microsoft Azure. References:
- Setup a static website (front-end assets get pushed here)
- Link the site to a CDN (moving the assets closer to users)
- Use my custom domains for the CDN (including HTTPS)
Here is an example of the GoDaddy DNS configuration used to serve content from an Azure CDN:
Type | Key | Value |
CNAME | www | domain.azureedge.net |
CNAME | cdnverify | cdnverify.domain.azuredge.net |
But I ran into a couple problems!
- Azure CDN does not assign SSL certs to apex/root domains. I could have manually assigned a certificate, but I’m trying to avoid having to do manual things these days.
- Requests to http://mydomain.com would not serve content! The name would not resolve. GoDaddy (my DNS provider at the time), does not allow us to create a CNAME pointing at an apex/root domain.
I could have purchased a public static IPv4 address from Azure, linked it to my CDN, and setup an ANAME in GoDaddy to point at the public IP. But, considering both problems (above), I decided to take the following action:
- Delegate my domain’s DNS to point at an Azure DNS Zone
- Setup my local network (OpenWRT) to use Cloudflare for DNS resolution (my ISP was taking too long to resolve when testing these changes).
- This is a nice alternative to Google’s 8.8.8.8/8.8.4.4…why give one company all your data?!
- Delete the Standard Akamai CDN, and setup a Standard Microsoft CDN, which has a comprehensive rules engine, and other goodies.
- Use the Rules Engine to enforce a consistent experience…
- Redirect HTTP requests for my apex/root via a 301 response to https://www.mydomain.com
- Redirect HTTPS requests for my apex/root via a 301 response to https://www.mydomain.com
- Redirect all other HTTP requests via a 301 to HTTPS
Now…all your base are belong to us! I mean, requests for http://mydomain.com (insecure root), https://mydomain.com (secure root), and http://www.mydomain.com (insecure www sub-domain) will redirect to https://www.mydomain.com.
So, I’m using the cloud for DNS, everything has a cost.For example, two million queries with one zone will cost $1.30. Sounds like a good problem to have!