Working as a cloud engineer you may ask yourself, is it possible to create a CNAME record for your root domain? The answer will be no for most of the hosting providers, but that’s not the case for Cloudflare. Cloudflare figured out that working on cloud, you don’t get static IPs especially if your app is deployed on some container orchestration services where you are working with load balancers. They finally manage to “hack” the DNS and announce the CNAME Flattening: RFC-Compliant CNAMEs at a Domain’s Root.
In this tutorial I will show you how to achieve this.
Prerequisites
- Cloudflare account
Solution
Step 1. Point your DNS Nameservers to Cloudflare Nameservers. You can find them in the DNS Cloudlflare section.
Step 2. Once your Nameservers are pointed to Cloudlflare ones and propagated, you should be able to create a CNAME for your root domain.
Step 2. To create CNAME for your root domain follow the order:
- Go to DNS Account Section.
- Click on the
+Add Record
button. - From the dropdown menu choose
CNAME
. - In the
Name
field put your root domain. For exampledevcoops.com
. - In the
Target
field put the alias name. For instance, I want to point my domaindevcoops.com
to point to AWS ALB internal load balancer:`Type` `Name` `Content` `TTL` `Proxy status` CNAME devcoops.com proxy-internal-alb.devcoops.com Auto DNS only
Conclusion
If you followed the steps above you can easily create CNAME for your own root domain. For any additional questions regarding this please put a comment below. If you find this tutorial useful share it with the rest of the tech community and follow our official channel on Telegram.