Before you can use the CNAME record mode with Web Application Firewall (WAF), you must first add the domain name that you want to protect to WAF. This topic describes how to add a domain name to WAF.
Prerequisites
-
You have purchased a WAF instance, and the number of domain names that it supports does not exceed the limit.
NoteThe total number of domain names that you can add to a WAF instance varies based on the specifications of the instance and the number of extra domain packages that you purchased. For more information, see extra domain package.
If your website is deployed on a server in the Chinese Mainland, the domain name must have an ICP filing that remains valid while protected by WAF.
NoteWAF instances in the Chinese Mainland periodically check the ICP filing status of protected domain names. If an ICP filing expires, WAF stops forwarding requests for the domain name and may clear its configuration to comply with relevant laws and regulations.
If the website is deployed on Alibaba Cloud, you must complete the ICP filing through Alibaba Cloud.
If the website is not deployed on Alibaba Cloud, you can contact Alibaba Cloud or another cloud provider to complete the ICP filing.
Procedure
-
Log on to the Web Application Firewall (WAF) console. In the top menu bar, select the resource group and region for your WAF instance: Chinese Mainland or Outside Chinese Mainland.
-
In the left navigation pane, choose .
On the Domain Names tab, click Website Access.
NoteOn the Add Domain Name page, Access Mode is set to CNAME Record by default.
Enter website information and click Next.
Parameter
Description
Domain Name
Enter the domain name that you want to protect. You can enter an exact domain name, such as
www.aliyundoc.com, or a wildcard domain name, such as*.aliyundoc.com. You can enter only one domain name.Domain names that contain underscores (
_) are not supported.If you are adding this domain name for the first time, you must verify its ownership before you can proceed.
NoteA wildcard domain name matches all subdomains at the asterisk's immediate level. For example,
*.aliyundoc.commatcheswww.aliyundoc.comandexample.aliyundoc.com, but notwww.example.aliyundoc.com.A second-level wildcard domain name does not match the corresponding apex domain. For example,
*.aliyundoc.comdoes not matchaliyundoc.com.Similarly, a multi-level wildcard domain name does not match its base domain. For example,
*.example.aliyundoc.comcannot matchexample.aliyundoc.com.If protection is configured for both an exact domain name and a wildcard domain name that matches the exact domain name, the protection rules and forwarding configurations for the exact domain name take precedence.
Protection Resource
Select the type of protection resource to use. The following options are available:
Public Cluster: This option is selected by default.
Exclusive Cluster: This option is available if you use an Exclusive Edition WAF instance. An exclusive cluster supports customized business requirements. For more information, see Best practices for exclusive clusters.
Hybrid Cloud Cluster: Select this option if you use a hybrid cloud deployment. For more information, see Add a website to WAF (Hybrid Cloud WAF).
Protocol Type
Select the protocol that the website uses. The following options are available:
HTTP
HTTPS
ImportantIf the website supports HTTPS encryption, select HTTPS. After you add the domain name, upload the certificate and private key file for the domain name. For more information, see Upload an HTTPS certificate.
If you select HTTPS, you can also enable the following features:
HTTP2 (This option is available only after you select HTTPS.)
If your website supports HTTP/2, you must enable this setting. The port for HTTP/2 is the same as the port for HTTPS. After you enable this setting, you need to only set the HTTPS port. For more information, see WAF FAQ.
NoteOnly Enterprise, Ultimate, and Exclusive editions of WAF instances support HTTP2.
Server Address
Specify the address of your origin server. You can specify an IP address or a Domain Name (Such as CNAME). WAF forwards filtered requests to this address.
IP address: Enter the public IP address of the origin server. The IP address must be accessible over the internet.
You can enter multiple IP addresses. Press the Enter key after you enter each IP address. You can add up to 20 origin IP addresses.
NoteIf you specify multiple IP addresses, WAF automatically performs health checks and load balancing among these addresses.
WAF instances Outside Chinese mainland support only IPv4 addresses. WAF instances in the Chinese mainland support the following configurations:
Specify both IPv4 and IPv6 addresses
If you enable Use the Same Protocol, requests from IPv6 addresses are forwarded to IPv6 origin servers, and requests from IPv4 addresses are forwarded to IPv4 origin servers. If you do not enable Use the Same Protocol, requests are forwarded to both IPv4 and IPv6 origin servers. This means that both IPv4 and IPv6 requests may be forwarded to IPv4 or IPv6 origin servers.
ImportantIf you use origin fetch over IPv6, you must make sure that the IPv6 Status of the domain name in the Website Access list is Enabled. For more information, see Enable IPv6 protection.
Specify only IPv4 addresses
Both IPv4 and IPv6 requests are forwarded over IPv4. WAF forwards requests to the IPv4 origin server addresses that you specify.
Specify only IPv6 addresses
Both IPv4 and IPv6 requests are forwarded over IPv6. WAF forwards requests to the IPv6 origin server addresses that you specify.
Domain Name (Such as CNAME): Enter the origin domain name of the server, such as the CNAME of an Object Storage Service (OSS) bucket.
If you specify a domain name, origin fetch over IPv4 is supported. WAF forwards client requests to the IPv4 address that is resolved from the origin domain name.
ImportantThe origin domain name of the server cannot be the same as the domain name of the website that you want to protect.
If the address of your origin server is an OSS domain name, you must go to the OSS console to attach a custom domain name to the OSS domain name after you add the website. For more information, see Attach a custom domain name.
Destination server port
Add the service ports that the website uses for forwarding.
WAF only accepts and forwards traffic on the ports you specify. Requests to other ports are dropped and will not reach your origin server.
ImportantThe specified Protocol Type and Destination server port must match the protocol and port your origin server is listening on. Port translation is not supported.
Default ports:
HTTP: Port 80 is used by default if you select the HTTP protocol.
HTTPS or HTTP2: Port 443 is used by default if you select the HTTPS protocol.
Custom ports: In the HTTP Port or HTTPS Port text box, enter a port and press the Enter key. Click View Port Range to query all supported ports.
NoteWAF Ultimate and Exclusive instances support up to 50 server ports, including ports 80, 8080, 443, and 8443. WAF Pro and Enterprise instances support up to 10 server ports.
For more information about the ports that are supported by a public cluster, see Ports supported by WAF.
If you want to add a website to a WAF exclusive cluster, you can select custom ports only from the Destination Server Port range that is specified on the Exclusive Cluster Configurations page. For more information, see Configure an exclusive cluster.
Load Balancing Algorithm
If you specify multiple origin server addresses, select a load balancing algorithm. The following options are available:
IP hash: Requests from the same client IP address are forwarded to the same origin server. Use this for applications that require session persistence (sticky sessions). Note that this may cause uneven load distribution.
Round-robin (Default): Requests from clients are sequentially forwarded to origin servers in the list of origin servers. This algorithm is suitable for scenarios in which multiple origin servers are used and an even distribution of load among the origin servers is required.
Least time: The intelligent DNS resolution feature and the upgraded least-time origin fetch algorithm are used to minimize the latency of the entire link, from when service traffic is routed to a protection node to when the traffic is forwarded to an origin server.
NoteThe least time algorithm is available only after you enable intelligent load balancing. For more information, see Intelligent load balancing.
After the settings take effect, WAF distributes origin fetch requests to multiple origin server addresses based on the specified load balancing algorithm to implement load balancing.
Is a Layer 7 proxy such as Anti-DDoS Proxy or CDN deployed in front of WAF
Enable Traffic Mark
Specifies whether to enable the traffic mark feature for WAF.
This feature adds a custom header to requests that WAF forwards to your origin server. This header can identify that the request was processed by WAF and can include information such as the client's originating IP address.
After you select Enable Traffic Mark, you must set the mark fields.
ImportantDo not enter standard HTTP header fields, such as User-Agent. Otherwise, the values of the standard header fields are overwritten by the custom field values.
If an attacker obtains the origin IP address before the domain name is added to WAF and purchases another WAF instance to forward requests to the origin server, you can Enable Traffic Mark and set mark fields. When the origin server receives a request, we recommend that you check this field. If the specified mark field exists, access is allowed.
The following types of mark fields are available:
Click Add Mark to add a mark field. You can set up to five mark fields.
Back-to-origin Timeout Configuration
Resource Group
From the resource group list, select the resource group to which the domain name belongs.
NoteYou can use Resource Management to create resource groups and manage cloud resources based on dimensions such as business departments and projects. For more information, see Create a resource group.
If the wildcard domain name corresponding to the domain name that you entered in Step 4 has been configured by another user, you must configure a TXT record according to the record type, domain name, and record value provided in the Note dialog box.
For example, if you use Alibaba Cloud DNS, you can log on to the Alibaba Cloud DNS console and configure a TXT record based on the information in the Note dialog box. For more information, see Add a DNS record.
Change the DNS record.
Follow the on-screen prompts to change the DNS record of the domain name to point it to WAF for protection. Then, click Next. For more information, see Change the DNS record of a domain name.
Complete the process.
Follow the on-screen prompts to add the back-to-origin IP addresses of WAF to the allowlist. Then, click Complete. Return to Domain Name List to return to the Website Access page. For more information, see Add the back-to-origin IP addresses of WAF to an allowlist.
Upload an HTTPS certificate
If you selected HTTPS for Protocol Type in Step 4, you must upload the domain name's HTTPS certificate to the WAF console. The certificate must be correct and valid for WAF to protect HTTPS requests to your website.
You can use one of the following methods to upload an HTTPS certificate:
Manually upload a certificate: You must prepare your website's certificate file and private key file in advance.
The following content is required. When you upload the certificate, make sure that it has a complete certificate chain:
*.crt (public key file) or *.pem (certificate file)
*.key (private key file)
Select an existing certificate: You can select the domain name's certificate from your existing certificates in Digital Certificate Management Service. For more information, see Digital Certificate Management Service.
Apply for a new certificate.
-
Log on to the Web Application Firewall (WAF) console. In the top menu bar, select the resource group and region for your WAF instance: Chinese Mainland or Outside Chinese Mainland.
-
In the left navigation pane, choose .
In the Domain Names list, find the domain name that you want to manage and click the
icon in the Origin Server column.NoteThe
icon appears in the Origin Server column only if you selected HTTPS as the protocol type when you added the domain name.In the Upload Certificate (or Update Certificate) dialog box, select an Upload Method and upload an HTTPS certificate.
NoteIf you have already uploaded a certificate, the Update Certificate dialog box is displayed. The configurations in the Update Certificate dialog box are the same as those in the Upload Certificate dialog box.
Manual Upload: Enter a Certificate Name. Then, copy the content of the domain name's certificate file and private key file and paste the content into the Certificate File and Private Key text boxes.
The following items describe the Certificate File parameter:
If the certificate is in the PEM, CER, or CRT format, you can use a text editor to open the certificate file and copy the content.
If the certificate is in a format other than PEM, CER, or CRT, such as PFX or P7B, you must convert the certificate file to the PEM format. Then, you can use a text editor to open the file and copy the content. For more information about how to convert certificate formats, see Convert an HTTPS certificate to the PEM format.
Make sure that you upload a complete certificate chain. If the domain name has multiple certificate files, you must combine the content of the files and then paste the combined content into the Certificate File text box.
Select Existing Certificate: From the Certificate list, select the certificate that you want to upload.
The Certificate list displays certificates issued by Digital Certificate Management Service. You can select a certificate for the current domain name from the list. Click Digital Certificate Management Service to go to the service's console and manage your certificates.
Purchase Certificate: Click Purchase Now to go to the Purchase Certificate page of Digital Certificate Management Service and apply for a certificate for the domain name.
After you follow the on-screen prompts to configure a certificate for the domain name, the certificate is automatically uploaded to WAF.
NoteYou can apply for only paid DV certificates. If you want to apply for other types of certificates, go to the SSL certificate purchase page. For more information, see Purchase a commercial certificate.
Click OK.
Next steps
After you add the domain name, WAF starts protecting your website traffic. You must also complete the following configurations to enhance your website's protection.
Configuration type | Description | References |
Website protection settings | WAF provides multiple protection modules to help you defend against different types of security threats. The Protection Rules Engine and HTTP Flood Protection modules are enabled by default to defend against common web application attacks, such as SQL injection, cross-site scripting (XSS), and webshell uploads, and HTTP flood attacks. You must manually enable other protection modules and configure protection rules. | |
Alert settings | By configuring alert rules, you can enable WAF to send you alert notifications when attack events or unusual traffic are detected in website requests. This helps you stay informed of the security status of your services. | |
Log Service settings | By enabling Log Service, you can allow WAF to collect and store log data of your website services for query and analysis. By default, WAF Log Service stores full logs of your website for 180 days to help you meet classified protection compliance requirements. |
Related operations
View and manage added domain names
After you add a domain name, you can view it in the Domain Names list on the Website Access page. From there, you can perform the following operations as needed:
Upload an HTTPS certificate: If your domain name supports HTTPS, make sure that you upload the correct certificate and private key to WAF. This ensures that WAF can protect HTTPS traffic. In the Origin Server column, you can click
to upload the HTTPS certificate and private key for the domain name.For more information, see Upload an HTTPS certificate.
Enable IPv6 protection: To protect IPv6 service traffic for your website, you can turn on the IPv6 switch for the domain name in the Quick Access column.
For more information, see Enable IPv6 protection.
Enable Log Service: After you turn on the Log Service switch for the domain name in the Quick Access column, WAF Log Service collects the full logs of your website. You can use these logs for queries, analysis, dashboard displays, and alert configurations. For more information, see Quickly use WAF Log Service.
NoteLog Service is a value-added service of WAF. You must activate the service before you can use it. For more information, see Step 1: Activate WAF Log Service.
Configure protection resources: To configure protection resources for a domain name, click the
icon next to Protection Resource in the Quick Access column.The following types of protection resources are available:
Shared Cluster and Shared IP Address (default)
Shared Cluster and Exclusive IP Address: For more information about exclusive IP addresses, see Exclusive IP address for a domain name.
Shared Cluster and Intelligent Load Balancing: For more information about global load balancing, see Intelligent load balancing.
Exclusive Cluster: For more information about exclusive clusters, see Configure an exclusive cluster.
View attack monitoring reports: In the Attack Monitoring column, click View Report to go to the Security Report page and view the protection reports for the domain name. For more information, see WAF security reports.
Set protection policies: In the Actions column, click Configure Protection to go to the Website Protection page. On this page, set protection policies for the Web Security, Bot Management, and Access Control/Throttling modules. For more information, see Overview of website protection settings.
Edit a domain name: In the Actions column, click Modify to modify website information, such as the protocol type, server address, and server port. You cannot modify the domain name.
Delete a domain name: In the Actions column, click Delete to delete the domain name.
WarningBefore you delete a domain name, change its DNS record to point to the origin IP address of the server. Otherwise, WAF can no longer forward traffic for the domain name after it is deleted.
After you add a domain name to WAF, make sure that its ICP filing information is valid. To comply with laws and regulations, WAF periodically checks the domain names added to it. If an ICP filing expires and is not renewed in time, the domain name's status changes to "not filed". In this case, WAF automatically stops forwarding traffic for the domain name. You must perform the following operations:
Complete the ICP filing for the domain name.
Go to the Website Access page. On the Domain Names tab, find the domain name with the completed ICP filing and click Add Again in the Actions column.
Manage ICP filings for domain names
After you add a domain name to WAF, make sure that its ICP filing information is valid. WAF periodically checks the domain names added to it. If an ICP filing expires and is not renewed in time, the domain name's status changes to "not filed". In this case, WAF automatically stops forwarding traffic for the domain name. You must perform the following operations:
Complete the ICP filing for the domain name.
Go to the Website Access page. On the Domain Names tab, find the domain name with the completed ICP filing and click Add Again in the Actions column.
DNS status of a domain
You can view the DNS status of your domain names in the list of added domain names. This helps you identify domain names with DNS resolution risks and modify DNS settings based on the causes of the exceptions displayed in the console.
DNS status | Actions |
Normal DNS resolution | The domain name's DNS resolves to WAF correctly. No action is required. |
Abnormal DNS resolution, A record used for access | You need to delete the A record for the domain name, add a CNAME record, and point it to the CNAME address provided by WAF. For more information, see Change the DNS record of a domain name. |
Abnormal DNS resolution, incorrect WAF IP used | You need to delete the A record for the domain name, add a CNAME record, and point it to the CNAME address provided by WAF. For more information, see Change the DNS record of a domain name. |
Abnormal DNS resolution, incorrect CNAME address used | You need to change the record value in the CNAME record to the CNAME address provided by WAF. For more information, see Change the DNS record of a domain name. |
Unknown DNS resolution, proxy enabled for the domain name | A Layer 7 proxy is deployed in front of WAF. Check whether the origin address of the proxy is the CNAME address provided by WAF. If the address is correct, you can ignore this alert. |
DNS check timed out | Click the |
No DNS record. Please add to WAF. | You need to add a CNAME record and set the record value to the CNAME address provided by WAF. For more information, see Change the DNS record of a domain name. |
DNS does not resolve to WAF. Please add to WAF. | You need to modify the CNAME record and set the record value to the CNAME address provided by WAF. For more information, see Change the DNS record of a domain name. |
Normal DNS resolution (Incorrect proxy configuration for the domain name) | The domain name's DNS resolves to WAF correctly, but the front-end proxy function is enabled by mistake. If no Layer 7 proxy such as a CDN or Anti-DDoS instance is deployed in front of WAF, set Is a Layer 7 proxy such as Anti-DDoS Proxy or CDN deployed in front of WAF to No. |
FAQ
Handling origin server IP changes
In the firewall or security group of the new origin server, add the back-to-origin IP address range of WAF to the allowlist.
Log on to the WAF console and update the Origin server address configuration for the corresponding domain name. You do not need to change the DNS record.
Handling the "Unknown DNS resolution" warningThe issue of unknown DNS resolution occurs.A proxy is deployed.
If a Layer 7 proxy such as a CDN or Anti-DDoS instance is deployed in front of WAF, set the "Is a Layer 7 proxy such as Anti-DDoS Proxy or CDN deployed in front of WAF:" option to "Yes" in the access configuration.
If this message appears after the setup is complete, this is expected behavior. This is because the domain name's DNS resolves directly to the front-end Layer 7 proxy, and WAF cannot directly obtain the resolution status. No additional action is required.
Resolving website mix-ups with shared IPs
This issue can occur when multiple domain names resolve to the same IP address, but the origin server is not configured to serve different content based on the request's Host header.
Check the origin server configuration: In the domain name list in the WAF console, check if the server addresses for different domain names point to the same set of origin IP addresses.
Verify virtual host configuration: Confirm that the origin server is configured to serve the correct website content based on the Host header in the HTTP request (that is, a separate virtual host is configured for each domain name).
Configure origin SNI: If multiple virtual hosts are deployed on the origin server, enable the "Enable Origin SNI" feature in the WAF console and set the value of the SNI extension field to Use Domain Name in Host Header.