This topic describes how to add a CNAME record to an Application Load Balancer (ALB) instance to map a custom domain name to the public domain name of the ALB instance.
Overview
A CNAME record is a type of DNS record that maps an alias name to another domain name. You can use a CNAME record to map a custom domain name to the domain name of your ALB instance so that your ALB instance can be accessed through the custom domain name. The following figure shows how a CNAME record works.
Prerequisites
An ALB instance is created. For more information, see Create an ALB instance.
Procedure
Log on to the ALB console.
In the top navigation bar, select the region where the ALB instance is deployed.
Find the ALB instance that you want to manage and copy its domain name.
To create a CNAME record, perform the following operations:
NoteIf your domain name is not registered by using Alibaba Cloud Domains, you must add your domain name to Alibaba Cloud DNS before you can configure a DNS record. For more information, see Manage domain names.
Log on to the Alibaba Cloud DNS console.
On the Authoritative DNS Resolution page, find your domain name and click DNS Settings in the Actions column.
On the DNS Settings tab of the domain name details page, click Add DNS Record.
In the Add DNS Record panel, configure the parameters and click OK. The following table describes the parameters.
Parameter
Description
Record Type
Select CNAME from the drop-down list.
Hostname
Enter the prefix of the domain name.
DNS Request Source
Select Default.
Record Value
Enter the CNAME, which is the domain name of the ALB instance.
TTL
Select a time-to-live (TTL) value for the CNAME record to be cached on the DNS server. In this example, the default value is used.
NoteAfter you create a CNAME record, it immediately takes effect. After you modify a record, the record takes effect based on the TTL of the record. By default, the TTL is 10 minutes.
If the CNAME record that you want to create conflicts with an existing record, we recommend that you specify another domain name. For more information, see Rules for conflicting DNS records.
What to do next
Check whether the CNAME record takes effect. Run the ping
or dig
command in your command-line interface (CLI) to access the custom domain name. If the ping or dig packet is redirected to the domain name of the ALB instance, it indicates that the CNAME record takes effect.
References
The following topics describe how to map multiple domain names to the domain name of an ALB instance to distribute requests to different backend servers: