This week, I'll be tackling the topic of DNS hostnames, and how you can configure and manage server availability with the help of Cloud 66 for high availability.
Each time a user tries to access your domain, a Domain Name System (DNS) service is used to translate the requested domain name into its corresponding IP address. Think of it as the internet's phone directory, allowing a users' computer to connect to the destination web server through locating its IP address in order to gain access to the information needed.
When it comes to using Cloud 66, we provide DNS hostnames for each server you deploy with us. This allows us to assign a new IP address to your application on your behalf if need be, while still maintaining the same hostname.
To get started, you'll first need to manage the DNS records of your domain name to make sure it’s pointing to Cloud 66. To secure maximum reliability, you should point it at a failover group address, which allows you to switch traffic between stacks quickly and easily.
You should (where possible) avoid using a DNS A-record, which would point directly at an IP address. Instead, use CNAME records to point your domain at a hostname (either your server hostname or a failover group address). However, this may not be possible with your DNS provider — while CNAME records do not require hard-coded IP addresses, they are not available to root domains (eg. example.com).
To use wildcard subdomains with Cloud 66 hostnames, simply create a CNAME record pointing *..com to your Cloud 66 hostname.
Configuring Your DNS
While there are 3 different approaches to how you can configure your DNS, we recommend the following in order of preference:
1. Using a Modern DNS Provider
Some DNS hosts provide a CNAME-like functionality at the zone apex (root domain) using a custom record type. There are several options out there to use, including ALIAS at DNSimple, ANAME at easyDNS or ALIAS at AWS.
The setup is similar for each provider — simply point the ALIAS or ANAME for your root domain to the Cloud 66 hostname.
2. Using an A Record
This method involves using an A record to point your root domain to your load balancer and then redirect traffic to www in NGINX.
- Create a CNAME record for www pointing at the Cloud 66 hostname on your load balancer.
- Create an A record for your root domain (eg. example.com) pointing at your load balancer IP address.
- Use network redirects to permanently redirect all traffic from example.com to www.example.com.
3. Subdomain Redirection
It's worth noting that this method will not work if you are serving content with SSL, and only works for HTTP traffic (eg. not TCP/UDP). This method creates a 301 permanent redirect to a specified subdomain for all root domain traffic.
- Create a DNS forward of example.com to www.example.com.
- Create a CNAME record with value www to the Cloud 66 hostname.
Thanks and happy coding.