Combining CDN and WAF to Get Improved Protection and Load Speed
How the Combination Works
- When a user accesses a website that uses HUAWEI CLOUD CDN, the local DNS server will redirect all domain requests to CDN using CNAME records. CDN uses a group of predefined policies (such as the content type, geographical location, and network load status) to respond visitors with the nearest CDN IP address so that visitors can obtain requested website content as quickly as possible.
Objects supported by CDN: domain names of web applications on HUAWEI CLOUD, other cloud platforms, or on-premises data centers
- Web Application Firewall (WAF) keeps web services stable and secure. It examines all HTTP and HTTPS requests to detect and block the following attacks: Structured Query Language (SQL) injection, cross-site scripting (XSS), web shells, command and code injections, file inclusion, sensitive file access, third-party vulnerability exploits, Challenge Collapsar (CC) attacks, malicious crawlers, and cross-site request forgery (CSRF). WAF offers the cloud, dedicated, and ELB mode to protect websites. You can add either domain names or IP addresses to WAF. Before you start, get familiar with the following differences:
- Cloud mode: protects your web applications on HUAWEI CLOUD, other cloud platforms, or on-premises data centers through domain names.
- Dedicated or ELB mode: protects your web applications on HUAWEI CLOUD through domain names or IP addresses.
The combination of CDN and WAF can protect websites on HUAWEI CLOUD, other clouds, or on-premises and improve website response time. Figure 1 shows the configuration diagram.
After you deploy CDN and WAF for your website, traffic is accelerated by CDN and then forwarded to WAF. WAF checks received traffic and forwards only the normal traffic to the origin server. The combination protects the website against attacks while improving the website response speed and availability.

The configurations are as follows:
- Cloud mode
Point your website domain name to CDN and then change the CDN back-to-source address to the WAF CNAME record. After that, you can also add a WAF subdomain name and TXT record on your DNS management platform in case others have connected the website domain name to WAF before you configure CDN.
- Dedicated mode
Resolve the website domain name to CDN and change the CDN back-to-source IP address to the EIP bound to the load balancer configured for dedicated WAF instance.
- ELB mode
Resolve the website domain name to CDN and change the CDN back-to-source IP address to the EIP bound to the load balancer configured for the dedicated WAF instance.
Prerequisites
The domain name or IP address has been connected to CDN, and the configuration in Table 1 have been completed.
| Deployment Mode | Description |
|---|---|
| Cloud |
NOTICE: To ensure that the WAF policy takes effect for the real source IP address, ensure that Yes is selected for Proxy Configured when you add the domain name to WAF. For details, see Viewing Basic Information |
| Dedicated mode |
|
| ELB mode |
Cloud WAF Configuration
The following uses HUAWEI CLOUD CDN as an example to describe how to configure domain name resolution. If you use HUAWEI CLOUD CDN, perform the following steps directly. If you use non-HUAWEI CLOUD CDN, configure domain name resolution on non-HUAWEI CLOUD CDN based on the instructions in the following steps.
- Obtain settings of CNAME, Subdomain Name, and TXT Record.
- Log in to the management console.
- Go to the Website Settings page by following the steps shown in Figure 2.
- In the Protected Website column, click the domain name you want to go to the Basic Information page.
- On the page for configuring basic domain information, click
in the row where the CNAME is located to copy CNAME. In the row of Access Status, click How to Access. In the Access Guide dialog box, copy Subdomain Name and TXT Record. Figure 3 Domain name access information
- Change the origin server domain name of the primary origin server of CDN to the CNAME of WAF.
- (Optional) Add a WAF subdomain name and TXT record at your DNS provider.
To prevent others from configuring your domain names on WAF in advance (this will cause interference on your domain name protection), this step is recommended.
- Access the DNS resolution page, as shown in Figure 4.
- In the upper right corner of the page, click Add Record Set. The Add Record Set page is displayed. Figure 5 shows an example.
- Name: TXT record copied in 1.d.
- Type: Select TXT – Specify text records.
- Alias: Select No.
- Line: Default
- TTL (s): The recommended value is 5 min. A larger TTL value will make it slower for synchronization and update of DNS records.
- Value: Add quotation marks to the TXT record copied in 1.d and paste them in the text box, for example, TXT record.
- Keep other settings unchanged.
- Click OK.
- (Optional) Ping the IP address of your domain name to check whether the new DNS settings take effect.
It takes some time for the new DNS settings to take effect. If ping fails, wait for 5 minutes and ping again.
Dedicated/ELB Mode WAF Configuration
Perform the following steps to complete configurations on HUAWEI CLOUD CDN:
- Log in to the management console.
- Click
in the upper left corner of the management console and select a region or project. - Click
in the upper left corner of the page, choose Storage > CDN. - In the navigation pane on the left, choose Domains.
- In the domain list, click the domain name you want to modify or click Settings in the Operation column.
- Click the Basic Settings tab. In the Origin Server Settings area, click Edit.
- In the Modify Origin Server dialog box displayed, modify the IP address of the origin server. Figure 6 shows an example.
- If you use a dedicated WAF instance, enter the EIP bound to the load balancer in the Origin text box.
- If you use a load-balancing WAF instance, enter the EIP bound to the load balancer configured for the WAF instance in the Origin text box.
- Click OK.
Verification
If Access Status is Accessible, the traffic destined for your website domain name or IP address is routed to WAF.
If WAF detects 20 access requests to a website within 5 minutes, WAF considers that the website has been successfully connected to WAF.
If a domain name fails to be connected to WAF, its access status is Inaccessible. To fix this issue, see Why Is the Access Status of a Domain Name or IP Address Inaccessible?
Last Article: Connecting a Domain to WAF for Websites with no Proxy Used
Next Article: Combining AAD and WAF to Get All-Round Protection





Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.