Point Services to Root Domain

2min

Using CNAME Record

Have you ever wanted to use yourdomain.com instead of blog.yourdomain.com or status.yourdomain.com?

You've probably wanted to use your main domain for web applications or services which only support subdomains and CNAME records. The problem with CNAME is that they cannot be placed at the root domain level because the root domain is the DNS Start of Authority (SOA) which must point to an IP address. That's true, but there's an easy workaround which I'll explain below.

In order for you to use your root domain with any web app or service, they need to provide you with the option of pointing your DNS A record to their IP address. In most cases, CNAME is provided for the ease of its implementation and manageability. In this example, I will be using Better Uptime which is an uptime monitoring service. Commonly, it is best to use the subdomain. Additionally, they only allow having a subdomain for their service, in this case, a status page. So normally I will create a new subdomain for a status page such as status.eg.sa but for the purpose of this demonstration, I will force it to use my root domain eg.sa.

Use Case

A common use case is using it with most blog services. blog.yourdomain.com > yourdomain.com

Implementation

The solution is to use Cloudflare for your DNS management. It allows you to override this restriction enabling you to point your root domain to any service address as seen below:

Cloudflare's DNS Dashboard
Cloudflare's DNS Dashboard


In the Cloudflare DNS screen, type in your root domain and the CNAME value that was provided by your web app, respectively. For SSL, make sure you set the proxy status to DNS only depending on the web app configuration. Now, instead of accessing status.eg.sa, my main domain became the status page. Feel free to reach me on twitter if you have any questions.