Updated on 2026-09-01 GMT+08:00

Connecting Your Website to WAF Using Cloud CNAME Access

No matter where your website service servers are deployed, on Huawei Cloud, other clouds, or on-premises data centers, you can use cloud CNAME access to connect your website to WAF.

Cloud CNAME access is a reverse proxy mode. It does not require you to change the public IP address of the origin server or the network architecture. To enable WAF protection, you only need to add your website to WAF and modify the DNS settings to route website traffic to WAF. After your website is connected to WAF, DNS resolves the domain name to WAF when website users access the domain name. WAF checks, scrubs, and filters out malicious requests, and then forwards normal requests to the origin server.

Video Tutorial

Overview

This section describes the principles of cloud CNAME access and website traffic flow after a website is connected to WAF.

Cloud CNAME access uses DNS resolution for traffic scheduling.
  • Without a proxy: DNS points the domain name to the CNAME record allocated by WAF. WAF then checks incoming traffic, filters out malicious traffic, and forwards legitimate traffic to the origin server. Figure 1 shows the process.
    Figure 1 Access principles (without a proxy)
  • With a proxy: DNS points the domain name to a proxy such as CDN or Advanced Anti-DDoS (AAD). You need to change the back-to-origin address of the proxy to the CNAME record allocated by WAF. WAF then checks incoming traffic, filters out malicious traffic, and forwards legitimate traffic to the origin server. Figure 2 shows the process.
    Figure 2 Access principles (with a proxy)

Figure 3 shows the traffic flow after a website is connected to WAF with cloud mode CNAME access.

Figure 3 Website traffic flow diagram.
The details are as follows:
  1. After a visitor enters a domain name in the browser, the client sends a request to the DNS service to query the domain name resolution address.
  2. DNS returns the domain name resolution address to the client.
  3. If no proxies (such as CDN or AAD) are used, the domain name resolution address returned by DNS is a WAF IP address. The client accesses WAF through the WAF IP address. For details about WAF IP addresses, see WAF IP Address. If a proxy is used:
    1. The domain name resolution address returned by DNS is the IP address of the proxy. The client accesses the proxy through the proxy IP address.
    2. The proxy then accesses WAF over a WAF IP address.

    In the cloud CNAME access scenario, if the origin server is attacked, WAF may switch over the WAF IP addresses mapped to the CNAME record. So, do not allow the WAF IP addresses mapped the CNAME record in the outbound of the request source (for example, Client or Proxy in Figure 3) in front of WAF. Otherwise, website services may be interrupted.

  4. WAF detects and blocks abnormal traffic, and forwards normal traffic to the origin server using WAF back-to-source IP addresses. For details about origin server and back-to-source IP address definitions, see Origin Server and Back-to-Source IP Address/Range.

Access Process

To connect your website to WAF for protection, you need to perform the following operations based on whether your website uses a proxy, such as AAD, CDN, and other cloud acceleration products.

Procedure

Description

Step 1. Add Your Domain Name to WAF

Add the target domain name and origin server information to WAF and configure listening and forwarding.

Step 2: Whitelist Back-to-Source IP Addresses on Your Origin Server

Obtain and allow WAF back-to-origin IP addresses to prevent them from being blocked by the origin server.

Step 3: Test WAF

Test website connectivity locally to verify domain name access configurations.

Step 4: Modify the DNS Records of the Domain Name

Change the DNS records of the domain name to point all public network traffic to WAF.

  • No Proxies Used: Point the DNS resolution to WAF CNAME record.
  • Proxies Used: Point the back-to-origin address of the proxy to the WAF CNAME record.

Step 5: Verify Website Access

Check whether a domain name is accessible after being connected to WAF and whether basic protection takes effect.

Constraints

  • In cloud mode CNAME access, WAF can only protect website domain names. If you need to configure a fixed access IP address, use Connecting Your Website to WAF Using Cloud Load Balancer Access.
  • If a domain name has both HTTP (layer 7) and layer-4 services, you cannot use cloud mode CNAME access. We recommend cloud mode load balancer access or dedicated mode to configure the listener corresponding to the layer-4 service on the ELB load balancer to forward requests to the origin server. In this way, layer-4 service requests are not forwarded to WAF, and only layer-7 service requests are forwarded to WAF.

Prerequisites

Basic Settings

You can take the steps below to quickly connect your website to WAF.

Step 1. Add Your Domain Name to WAF

When adding a protected domain name, you simply need to configure Basic Settings. Retain the default settings for Advanced Settings. After the website is connected, you can adjust the advanced settings based on your service requirements. For details, see Advanced Settings.
  • Basic Settings include Protected Domain Name, Protected Port, Server Configuration and IP Tag.
  • Advanced Settings include Minimum TLS Version, Cipher Suite, Load Balancing Algorithm, IPv6 Protection, HTTP/2, and Policy.
  1. Log in to the WAF console.
  2. Click in the upper left corner and select a region or project.
  3. (Optional) If you have enabled the enterprise project function, in the upper part of the navigation pane on the left, select your enterprise project from the Filter by enterprise project drop-down list. Then, WAF will display the related security data in the enterprise project on the page.

    You cannot add websites to all projects.

  4. In the navigation pane on the left, choose Access Management.

    Before adding a website to WAF, you can click Usage Guide in the upper right corner of the page to learn about the access process.

  5. On the Access Management page, click the Cloud CNAME tab and click Add Website.

    If only one access mode is enabled, click Add Website.

  6. On the Add Website panel, configure Basic Settings.

    Figure 4 Configuring basic information
    Table 1 Parameter description

    Parameter

    Description

    Example Value

    Protected Domain Name

    The domain name you want to add to WAF for protection.
    • You can add the following types of domain names:
      • Single domain names, such as top-level domain name example.com or second-level domain name www.example.com.
      • Wildcard domain names, such as *.example.com
        • The starter edition does not support adding wildcard domain names to WAF.
        • If the server IP address of each subdomain name is the same, enter a wildcard domain name. For example, if subdomain names a.example.com, b.example.com, and c.example.com have the same server IP address, you can add wildcard domain name *.example.com to WAF to protect all three.
        • If the server IP addresses of subdomain names are different, add subdomain names as single domain names one by one.
        • Each domain name must have a valid certificate associated. A wildcard domain name can only use a wildcard domain certificate. If you only have single-domain certificates, you need to add domain names to WAF one by one.
    • If a domain name uses different ports, each combination of the domain name plus a port is a unique protection object. For example, if you add www.example.com:8080 and www.example.com:8081 to WAF, they are considered as two domain names and counted towards two domain names in your quota.
    • If your origin server is located in the Chinese mainland, the associated domain name must have a valid Internet Content Provider (ICP) filing. WAF checks the ICP filing of domain names you want to add to WAF. If a domain name does not have an ICP filing, it cannot be added to WAF.

    You can click Quick Add Domain Names Hosted on this Cloud and select a domain name used in Huawei Cloud. The domain name must be a public domain name on DNS. If no domain name is available, go to Domain Name Service (DNS) to add one.

    www.example.com

    Website Name (Optional)

    Website name you specify.

    WAF

    Website Remarks (Optional)

    Remarks of the website.

    waftest

    Protected Port

    Port to be protected. Only one port can be added for a protected domain name. If you want to protect more ports for a domain name, add the domain name and each port to WAF by referring to Step 1. Add Your Domain Name to WAF.
    • To protect port 80 or 443, select Standard port from the drop-down list.
    • To protect other ports, choose one from the drop-down list. Click View Ports You Can Use to view the HTTP and HTTPS ports supported by WAF. For more information, see Ports Supported by WAF.

      If a port other than 80 or 443 is configured, the visitors need to add the non-standard port to the end of the website address when they access the website. Otherwise, a 404 error will occur. If a 404 error occurs, see How Do I Troubleshoot 404/502/504 Errors?

    Standard ports

    Server Configuration

    Configure the origin server information, including:

    • Client Protocol: protocol used by a client to access the website server. The options are as follows:
      • HTTP: If you select Standard port for Protected Port, port 80 is protected by default for HTTP.
      • HTTPS: If you select Standard port for Protected Port, port 443 is protected by default for HTTPS.
        • Hypertext Transfer Protocol Secure (HTTPS) is an extension of the Hypertext Transfer Protocol (HTTP). In HTTPS, the communication protocol is encrypted using Transport Layer Security (TLS) or, formerly, Secure Sockets Layer (SSL). HTTPS is widely used to protect privacy and integrity of data in transit and to authenticate website identities. So, if HTTPS is selected, you need to configure a certificate.
        • If you select HTTPS, you can enable HTTP/2. For details, see Enabling the HTTP/2 Protocol.
    • Server Protocol: protocol used by WAF to forward requests to the website server. You can select HTTP or HTTPS.

      If the client protocol is different from the origin server protocol, WAF forcibly uses the origin server protocol to forward client requests.

    • Server Address: the public IP address or domain name of your website server that the client accesses.
      • The public IP address typically maps to the A record of your domain name hosted in the DNS platform. The following IP address formats are supported:
        • IPv4 address, for example, XXX.XXX.1.1
        • IPv6 address, for example, fe80:0000:0000:0000:0000:0000:0000:0000. Only professional and enterprise editions support IPv6.
      • The domain name typically maps to the CNAME record of your domain name in the DNS platform.
    • Server Port: service port over which the WAF instance forwards client requests to the origin server.
    • Weight: Requests are distributed across backend origin servers based on the load balancing algorithm you select and the weight you assign to each server. This function is only supported in professional and enterprise editions for cloud mode.
      • If you select the weighted round robin algorithm, requests are distributed across origin servers in turn based on the weight you assign to each origin server.
      • If you select the source IP hash or session hash algorithm, the weight only determines whether traffic is distributed. If the Weight is 0, traffic is not distributed. If the Weight is not 0, traffic is distributed.
      • Weight range: 0 to 65,536. A larger weight indicates more requests distributed to the server.
      • If the weight is set to 0, the origin server will not accept new requests if multiple origin servers are configured. If only one origin server is configured, all requests are distributed to the origin server.
    • Remarks (Optional): Enter remarks about the server.
    • Client Protocol: HTTP
    • Server Protocol: HTTP
    • Server Address: XXX.XXX.1.1
    • Server Port: 80

    Certificate

    If you select HTTPS for Client Protocol, you need to select the certificate associated with the website. International websites are supported.

    • Each domain name must have a valid certificate associated. A wildcard domain name can only use a wildcard domain certificate. If you only have single-domain certificates, you need to add domain names to WAF one by one.
    • If your website certificate is about to expire, purchase a new certificate before the expiration date and update the certificate associated with the website in WAF.

      WAF can send notifications if a certificate expires. You can configure such notifications on the Notifications page. For details, see Enabling Alarm Notifications.

    You can import a new certificate, select an SCM certificate, or select an existing certificate.
    • Importing a certificate: If you have not created a certificate, click Import New Certificate. In the Import New Certificate dialog box, set certificate parameters. For more details, see Uploading a Certificate.

      Only .pem certificates can be used in WAF. If the certificate is not in PEM format, convert it into PEM first. For details, see How Do I Convert a Certificate into PEM Format?

      The newly imported certificates will be listed on the Certificates page as well.

    • Selecting an existing certificate: If you have created a certificate in WAF, click the drop-down arrow, select Existing certificates, and select a correct and valid certificate from the list.
    • Selecting an SCM certificate: If you have used a CCM certificate under the same account, you can select an SSL certificate from the drop-down list. The name of the SSL certificate you select must be the same as that in CCM.
      • Currently, certificates purchased in Huawei Cloud SCM can be pushed only to the default enterprise project. For other enterprise projects, SSL certificates pushed by SCM cannot be used.
      • A record is automatically generated for the selected SSL certificate on the Certificates page. You can change the certificate name on this page, but the certificate name displayed in CCM will not be changed accordingly.

    -

    Minimum TLS Version and Cipher Suite

    After selecting a certificate, you need to select the minimum TLS version and cipher suite. For more details, see Configuring PCI DSS/3DS Compliance Check and TLS.
    • Minimum TLS Version: To be compatible with most service scenarios, the default minimum TLS version is TLS v1.0. You can select a more secure TLS version by referring to Table 1. You can select TLS v1.0, TLS v1.1, or TLS v1.2. Later versions are more secure than earlier ones.
    • Cipher Suite: To balance security and compatibility, the default cipher suite is Secure cipher suite. You can select a more secure cipher suite by referring to Table 2.
    • Minimum TLS version: TLS v1.0
    • Cipher suite: Secure cipher suite

    IP Tag

    After a website is connected to WAF, Use Layer-7 Proxy is set to Yes by default. In this scenario, WAF is unable to directly obtain the real IP address of the client. This makes IP address-based protection rules become invalid. You can select an IP tag to specify how WAF identifies client IP addresses. This enables WAF to obtain real client IP addresses.
    • $remote_sockaddr: If there is no other proxy in front of WAF, the packet contains the TCP Option Address (TOA), but you do not want WAF to use the TOA as the client IP address, select this option. With this tag configured, WAF uses the Layer 3 source IP address of the packet as the real client IP address.
    • $remote_addr: If there is a layer-4 proxy in front of WAF, WAF uses the TCP connection IP address as the real client IP address.
    • x-forwarded-for: If there is a layer-7 proxy in front of WAF, WAF uses the first IP address in the X-Forwarded-For (XFF) header as the real client IP address.
    • Custom: If there is a layer-7 proxy in front of WAF, WAF preferentially obtains the real client IP address from the configured field. If multiple fields are configured, WAF reads the real client IP address from left to right.

      If WAF does not obtain the real client IP address from the custom field, it reads the CDN-Src-Ip, X-Real-Ip, X-Forwarded-For, and $remote_addr fields in sequence to obtain the real client IP address.

    $remote_sockaddr

  7. Complete Advanced Settings.

    Figure 5 Advanced Settings
    Table 2 Advanced settings

    Parameter

    Description

    Example Value

    Load Balancing Algorithm

    If there are multiple origin server addresses, you need to select a load balancing algorithm for the origin servers so that WAF can forward requests to the corresponding server. For details, see Modifying the Load Balancing Algorithm.

    WAF supports the following algorithms:
    • Origin server IP hash: Requests from the same IP address are routed to the same backend server.
    • Weighted round robin: All requests are distributed across origin servers in turn based on weights set to each origin server. The origin server with a larger weight receives more requests than others.
    • Session hash: Requests with the same session tag are routed to the same origin server. To enable this algorithm, configure traffic identifiers for known attack sources, or Session hash algorithm cannot take effect.

    Weighted round robin

    IPv6 Protection

    If the domain name is accessible using an IPv6 address, enable IPv6 Protection. After you enable it, WAF assigns an IPv6 address to the domain name. Only professional and enterprise editions support IPv6 protection. For details, see Enabling IPv6 Protection.
    • If you select IPv6 for Server Address, IPv6 Protection will be enabled by default.

      If the origin server uses IPv6 addresses, IPv6 protection is enabled by default. To prevent IPv6 service from interruption, keep the IPv6 protection enabled. If IPv6 protection is not needed, edit the server configuration and delete IPv6 configuration from the origin server first. For details, see Editing Server Information.

    • If you select IPv4 for Server Address and enable IPv6 Protection, WAF will assign an IPv6 address to the domain name so that the website is accessible over the IPv6 address. In this way, requests to the IPv6 address are routed by WAF to the IPv4 address of the origin server. For details, see How Does WAF Forward Traffic to an IPv6 Origin Server?

    Enabled

    HTTP/2

    HTTP/2 cannot be configured unless you set Client Protocol to HTTPS for at least one origin server address record in Server Configuration. Only professional and enterprise editions support HTTP/2.

    HTTP/2 is only used for communication between clients and WAF. You can enable this function if your website needs to support HTTP/2 access. After HTTP/2 is enabled, ensure that the client supports TLS 1.2. Otherwise, HTTP/2 does not take effect.

    Use

    Policy

    Select the protection policy you want to use for the website.
    • System-generated policy (default): For details, see Table 3. If the number of added protection policies reaches the quota, this option will be grayed out.
    • A protection policy created manually: a custom policy you create based on your security requirements. Only the standard, professional, and enterprise editions support manually created protection policies. For more information, see Configuring Protection Policies.

    System-generated policy

    Table 3 Parameters for system-generated policies

    Policy

    Description

    Basic Web Protection: General Check is enabled by default.
    • Rule Set: Default rule set (medium) is selected.
    • Protective Action: Log only is selected. It means WAF only logs detected attacks but does not block them.

    The basic web protection defends against attacks such as SQL injections, XSS, remote overflow vulnerabilities, file inclusions, Bash vulnerabilities, remote command execution, directory traversal, sensitive file access, and command/code injections.

    Anti-Crawler: By default, Scanner detection is enabled, and Protective Action is set to Log only. WAF only logs detected attacks but does not block them.

    WAF only logs web scanning tasks, such as vulnerability scanning and virus scanning, such as crawling behavior of OpenVAS and Nmap.

  8. Click Next and complete the following operations as prompted in Test WAF:

    Figure 6 Domain name added
    1. Whitelist WAF Back-to-Source IP Addresses on Your Origin Servers
    2. Testing WAF
    3. Modifying DNS Records for a Domain Name

Step 2: Whitelist Back-to-Source IP Addresses on Your Origin Server

A back-to-source IP address is a source IP address used by WAF to forward client requests to origin servers. To origin servers, all access IP addresses are WAF back-to-source IP addresses. Real client IP addresses are encapsulated into the HTTP X-Forwarded-For (XFF) header field.

If the origin server uses other firewalls, network ACLs, security groups, or antivirus software, they are more likely to block WAF back-to-source IP address as malicious ones. So if the origin server's IP address is exposed, attackers can then bypass WAF and directly attack the origin server using that address. To prevent this, configure an access control policy on the origin server to allow only traffic from WAF back-to-source IP addresses on all ports.

  • There will be more WAF IP addresses due to scale-out or new clusters. For your legacy domain names, WAF IP addresses usually fall into several class C IP addresses (192.0.0.0 to 223.255.255.255) of two to four clusters.
  • Generally, these IP addresses do not change unless clusters in use are changed due to DR switchovers or other scheduling switchovers. Even when WAF cluster is switched over on the WAF background, WAF will check the security group configuration on the origin server to prevent service interruptions.
  1. Obtain WAF back-to-source IP addresses.

    After finishing Step 1. Add Your Domain Name to WAF, expand Step 1: (Optional) Whitelist WAF back-to-source IP addresses and click to copy all back-to-origin IP addresses. Alternatively, go to the Access Management page, locate the target domain name, and click Whitelist WAF in the Access Status column. Then, click to copy all back-to-origin IP addresses.
    Figure 7 Copying the back-to-source IP addresses

  2. Open the security software on the origin server and add the copied IP addresses to the whitelist.

    • If origin servers are deployed on ECSs, see Whitelisting WAF Back-to-Source IP Addresses on Origin Servers That Are Deployed on ECSs.
    • If origin servers are added to backend servers of an ELB load balancer, see Whitelisting WAF Back-to-Source IP Addresses on Origin Servers That Use Load Balancers.
    • If you also use Cloud Firewall (CFW) on Huawei Cloud, refer to Adding a Protection Rule.
    • If your website is deployed on servers on other cloud vendors, whitelist the WAF back-to-source IP addresses in the corresponding security group and access control rules.
    • If only the personal antivirus software is installed on the origin server, the software does not have the interface for whitelisting IP addresses. If the origin server provides external web services, install the enterprise security software on or use Huawei Cloud Host Security Service (HSS) for the server. These products identify the sockets of some IP addresses with a large number of requests and occasionally disconnect the connections. Generally, the IP addresses of WAF are not blocked.

  3. After the preceding operations are complete, click Whitelist configured.

Step 3: Test WAF

After adding a domain name to WAF and whitelisting WAF back-to-source IP addresses, you still need to point the domain name resolution to the IP address of WAF. To this end, you need to modify the hosts file on the local computer and configure domain name resolution mappings, which are DNS resolution records that take effect only on the local computer. After that, access the protected domain name through the local computer to check whether access settings of the domain name are valid. This prevents website access exceptions caused by abnormal domain name access configuration.

Before performing this operation, ensure that:

  1. Obtain the CNAME record.

    • Method 1: After finishing Step 2: Whitelist WAF back-to-source IP addresses, expand Step 2: Test WAF and copy CNAME record on the displayed page. Alternatively, go to the Access Management page, click Test WAF in the Access Status column, and copy the CNAME record on the displayed page.
    • Method 2: Choose Assets > Protected Objects. Click a domain name. On the basic information page that is displayed, click under CNAME to copy its value.

  2. Ping the CNAME record and record the corresponding IP address.

    Use www.example.com as an example and the WAF CNAME record is xxxxxxxdc1b71f718f233caf77.waf.huaweicloud.com.

    Open cmd in Windows or bash in Linux and run the ping xxxxxxxdc1b71f718f233caf77.waf.huaweicloud.com command to obtain the WAF access IP addresses. As shown in Figure 8, the WAF access IP address is displayed.
    Figure 8 ping cname

    If no WAF access IP addresses are returned after you ping the CNAME record, your network may be unstable. You can ping the CNAME record again when your network is stable.

  3. Add the domain name and WAF access IP addresses pointed to CNAME to the hosts file.

    1. Use a text editor to edit the hosts file. In Windows, the location of the hosts file is as follows:
      • Windows: C:\Windows\System32\drivers\etc
      • Linux: /etc/hosts
    2. Add a record like Figure 9 to the hosts file. The IP address is the WAF access IP address obtained in 2 and the domain name is the protected domain name.
      Figure 9 Adding a record
    3. Save the changes and then test the connectivity of the protected domain name through the CLI.
      Figure 10 Pinging the domain name

      It is expected that the resolved IP address is the access IP address of WAF obtained in 3.b. If the origin server address is returned, refresh the local DNS cache. (Run ipconfig/flushdns in Windows cmd or systemd-resolved in Linux Bash.)

  4. Verify the access.

    1. Clear the browser cache and enter the domain name in the address bar to check whether the website is accessible.

      If the domain name has been resolved to WAF back-to-source IP addresses and WAF configurations are correct, the website is accessible.

    2. Manually simulate simple web attack commands (for example, <Protected domain name>/?id=1 and 1=1, where id=1 and 1=1 is the SQL injection attack code used for testing) to see if web attack requests can be blocked.
      1. Set the mode of Basic Web Protection to Block. For details, see Enabling Basic Web Protection.
      2. Clear the browser cache, enter the test domain name (for example, <Protected domain name>/?id=1 and 1=1) in the browser to simulate a web attack, and check whether WAF blocks the attack. Figure 11 shows an example.
        Figure 11 Request blocked
      3. In the navigation pane on the left, choose Events to view test data.

  5. Verify that the preceding steps are complete and click Finished.

Step 4: Modify the DNS Records of the Domain Name

After a domain name is added to WAF, WAF functions as a reverse proxy between the client and server. The real IP address of the server is hidden, and only the IP address of WAF is visible to web visitors. You must point the DNS resolution of the domain name to the CNAME record provided by WAF. In this way, access requests can be resolved to WAF. After your website connectivity with WAF is tested locally, you can go to the DNS platform hosting your domain name and resolve the domain name to WAF. Then WAF protection can work.

Before modifying the DNS records of a domain name, ensure that:

  • You have the permission to modify domain name resolution settings on the DNS platform hosting your domain name.

The DNS configurations vary depending on whether a proxy is used before WAF.

  1. Obtain the CNAME record of WAF.

    • Method 1: After finishing Step 3: Test WAF, expand Step 3: Change DNS Resolution, and copy the CNAME record on the displayed page. Alternatively, go to the Cloud CNAME tab, locate the target domain name, and click Modify DNS in the Access Status column. Then, copy the CNAME record on the displayed page.
      Figure 12 Obtaining WAF CNAME record
    • Method 2: Choose Assets > Protected Objects. Click a domain name. On the basic information page that is displayed, click under CNAME to copy its value.

  2. Change the DNS records of the domain name to the WAF CNAME record.

    Configure the CNAME record at your DNS provider. For details, contact your DNS provider.

    The following uses Huawei Cloud DNS as an example to show how to configure a CNAME record. The following configuration is for reference only.

    1. Go to the Public Zones page.
    2. In the Operation column of the target domain name, click Manage Record Set. The Record Sets tab page is displayed.
      Figure 13 Record sets
    3. In the row containing the desired record set, click Modify in the Operation column.
    4. In the displayed Modify Record Set dialog box, change the record value.
      Figure 14 Modify Record Set
      Table 4 Modify Record Set

      Parameter

      Description

      Example Value

      Type

      Record set type. The record set type is CNAME.

      • The CNAME record must be unique for the same host record. You need to change the existing CNAME record of your domain name to WAF CNAME record.
      • Record sets of different types in the same zone may conflict with each other.

        For example, for the same host record, the CNAME record conflicts with other records such as A record, MX record, and TXT record.

        If the record type cannot be directly changed, you can delete the conflicting records and add a CNAME record. Deleting other records and adding a CNAME record should be completed in as short time as possible. If no CNAME record is added after the A record is deleted, domain resolution may fail.

      • For details about the restrictions on domain name resolution types, see Why Is a Message Indicating Conflict with an Existing Record Set Displayed When I Add a Record Set?

      CNAME

      Name

      Prefix of the domain name to be resolved. By default, this parameter is left blank.

      For example, if the domain name is example.com, its prefix can be:

      • www: used for website resolution. The domain name to be resolved is www.example.com.
      • Left blank: used for website resolution. The domain name to be resolved is example.com.

        If the host record is left blank, it can also be used to add resolution for the empty domain name @.

      • abc: used for subdomain name resolution. The domain name to be resolved is abc.example.com, which is a subdomain name of example.com.
      • mail: used for email address resolution. The domain name to be resolved is mail.example.com.
      • *: used for wildcard resolution. The domain name to be resolved is *.example.com, which matches all subdomain names of example.com.

      www

      Line

      Resolution line. The DNS server will return the IP address of the specified line, depending on where the visitor comes from. The default value is Default.

      Default

      TTL (s)

      The length of time (in seconds) for which a local DNS server caches a record set. Default value: 300. Value range: 1 to 2147483647.

      If your service address changes frequently, set a smaller TTL. Otherwise, set a larger value.

      300

      Value

      Enter the alias to which you want to point. Only one domain name can be entered. In this case, enter the WAF CNAME address copied in 1.

      Do not set the protected domain name to the IP address corresponding to the CNAME record.

      xxxxxxxdc1b71f718f233caf77.waf.huaweicloud.com

      Advanced Settings (Optional)

      Configure the alias, weight, and description of the record set. Retain the default value.

      --

    5. Click OK.

      Check the record you just added in the record set list. When the status changes to Normal, the record set has been modified.

  1. Obtain the CNAME record of WAF.

    • Method 1: After finishing Step 3: Test WAF, click Step 3: Change the back-to-source IP address of the proxy. On the displayed page, copy the CNAME record. Alternatively, go to the Access Management page, click Change Proxy IP Address in the Access Status column, and copy the CNAME record on the displayed page.
      Figure 15 Obtaining WAF CNAME record (1)
    • Method 2: Choose Assets > Protected Objects. Click a domain name. On the basic information page that is displayed, click under CNAME to copy its value.

  2. Make sure the domain name has been pointed to the proxy and change the back-to-source IP address of the used proxy, such as anti-DDoS and CDN services, to the copied CNAME record.

    To prevent other users from configuring your domain names on WAF in advance (this will cause interference on your domain name protection), add the subdomain name and TXT record on your DNS management platform.

    1. Obtain the subdomain name and TXT record: On the top of the domain name basic information page, click next to Inaccessible. In the dialog box displayed, copy the subdomain name and TXT record.
    2. Add Subdomain Name at the DNS provider and configure TXT Record for the subdomain name. For details about the configuration method, see What Are Impacts If No Subdomain Name and TXT Record Are Configured?

    WAF determines which user owns the domain name based on the configured Subdomain Name and TXT Record.

Configuration verification

After completing the preceding configurations, you need to check the CNAME record of the domain name.

  1. In Windows, choose Start > Run. Then enter cmd and press Enter.
  2. Run a nslookup command to query the CNAME record.

    If the configured CNAME record is returned, the configuration is successful. An example command response is displayed in Figure 16.

    Using www.example.com as an example, the output is as follows:

    nslookup www.example.com
    Figure 16 Querying the CNAME

  3. After the preceding steps are complete, select Finished.

Step 5: Verify Website Access

  • Verifying the access status
    After the access configurations are finished, WAF automatically checks the access status of new or updated domain names every 30 minutes based on the following conditions: If the domain name was created more than two weeks ago and has not been modified in the past two weeks, you can click in the Access Status column to manually refresh the access status.
    • Check whether a CNAME record or TXT record is configured for the website domain name if proxies are used.
    • Check whether there is traffic passing through the website. You can check whether the number of access requests to the website in the past day reaches 50. For example, if the website was successfully connected to WAF at 14:50, there were at least 50 requests to the website within the last day (from 14:50 the previous day to 14:50 the current day).

    Figure 17 shows the logic for checking the access status.

    Figure 17 Access status check logic
    You can check the domain name access status on the Cloud CNAME tab.
    • Accessible: The domain name has been connected to WAF. A CNAME record or a TXT record has been configured for the domain name, and the website has traffic.
    • Inaccessible: The domain name has not been connected to WAF. No CNAME or TXT record has been configured for the website domain name, and no traffic passes through the website. You can allow the back-to-source IP addresses, test WAF, or modify the DNS resolution based on the access status. If the domain name is still Inaccessible after you manually refresh the access status, connect the domain name to WAF again by referring to Why Is My Domain Name or IP Address Inaccessible?
    • DNS error: The website domain name has a TXT record, but the website does not have traffic. You can access the website more than 50 times within the last day, manually refresh the access status, and check whether the access status is updated to Accessible.
  • Protection Verification

    Manually simulate simple web attack commands (for example, <Protected domain name>/?id=1 and 1=1, where id=1 and 1=1 is the SQL injection attack code used for testing) to verify that WAF protection works.

Advanced Settings

When you perform Basic Settings and certain conditions are met, you can configure Minimum TLS Version and Cipher Suite, IP Tag, Load Balancing Algorithm, IPv6 Protection, HTTP/2, and Policy. You can retain the default settings for these configuration items. You can also adjust them based on your actual service requirements.

You can choose Assets > Protected Objects, click the website domain name, and configure these items on the website details page.

Cloud CNAME access supports the following advanced settings.
Table 5 Advanced settings

Function

Supported Function

HTTPS security hardening

  • Configuring PCI DSS/3DS Compliance Check and TLS: To balance compatibility and security, WAF uses TLS v1.0 as the minimum TLS version and secure cipher suites by default. You can configure a more secure TLS version and cipher suite based on your service requirements. You can also enable PCI DSS and PCI 3DS. With these measures, you can identify compliance risks, encrypt transmission, and prevent frauds, keeping services secure and compliant.
  • Enabling the HTTP/2 Protocol: This is used for HTTP/2 access between the client and WAF.
  • Enabling Cookie Security Attributes: If you enable this function, WAF automatically adds the HttpOnly and Secure attributes (both set to true) to the cookies returned by your origin server. This prevents security risks such as cross-site scripting (XSS) attacks, cookie hijacking, and man-in-the-middle (MITM) attacks. It also helps meet security compliance requirements and prevents web security scanners such as AppScan, AWVS, and NSFOCUS from recording the cookies as security threats.

Forwarding requests while preserving the original client IP addresses

Back-to-origin link and performance optimization

  • Configuring a Timeout for Connections Between WAF and a Website Server: You can configure a timeout for each key step in the process. If the request or response time exceeds the configured threshold, WAF terminates the process and returns an error code. This prevents long-term request blocking and unexpected resource usage.
  • Enabling Break Protection to Protect Origin Servers: This feature prevents website breakdowns caused by frequent 502 Bad Gateway or 504 Gateway Timeout errors or request processing delays.
  • Enabling Open Tracing: If you enable open tracing, you can trace complete request links based on access logs to obtain the request source, nodes that the request passes through, and response time. This helps you quickly locate and resolve service problems.

Network extension and high availability configuration

  • Enabling WAF IPv6 Protection: This feature can defend against web attacks and malicious traffic intrusions on IPv6 networks, and enable seamless communication between IPv6 and IPv4 origin servers, helping with IPv6 services compliance and security.
  • Modifying the Load Balancing Algorithm: You can select a load balancing algorithm to distribute traffic based on HTTP and HTTPS request characteristics, such as the source IP address and session ID.
  • Stopping WAF from Inserting Cookie Fields: WAF does not insert HWWAFSESTIME and HWWAFSESID into response cookies.
  • Modifying the Alarm Page: You can configure the custom page that WAF returns when a visitor request is blocked.
  • Modifying a Verification Code: This feature ensures compatibility between WAF protection actions and your service system, preventing service process interruptions or frontend parsing exceptions caused by status code mismatch.

Improved O&M monitoring efficiency

  • Configuring a Response Body Length in Logs: You can specify a response body length, and the system will log only those responses that meet the specified length.
  • Configuring a Custom Log Trace ID: You can configure custom log trace IDs, and WAF extracts and records custom request or response header fields into the custom_traceid field in WAF logs. A unified trace ID is used to connect the entire link from the frontend, WAF, gateway, to the backend service. In doing this, WAF logs and service logs are associated. This greatly improves the efficiency of log tracing, troubleshooting, and security incident investigation.

Configuration Suggestions for Your Production Environment

To ensure your service security and stability, take up the following suggestions before connecting service domain names to WAF:

  • Access time: Change DNS resolution during off-peak hours to minimize the impact on your customers.
  • Gray policy: Connect domain names for the non-production environment first. After your services run properly for a period of time, connect the domain names for the corresponding production environment.
  • Service checks: After the access is complete, you can check whether the services are normal in the following ways:
    • Viewing logs: Check whether the proportion of status code 200 fluctuates significantly and whether the QPS increases or decreases sharply. You can perform a check by referring to Querying a Protection Event.
    • Service monitoring: Check whether service functions, such as user visits and transactions, are normal.
  • Hardening origin servers: Configure an access control policy on your origin server to allow only WAF back-to-origin IP addresses to access the origin server on any ports. This prevents hackers from bypassing WAF to attack origin servers.
  • HTTPS configuration: Deploy an SSL certificate on both your origin server and WAF. Follow the configuration suggestions below to efficiently manage the certificate.
  • Rule optimization: Observe services for a period of time before enabling a rule to ensure that no normal requests are blocked mistakenly. For details, see Configuring Core Protection Rules.
  • Monitoring and alarms:
    • Enable alarm notifications by referring to Enabling Alarm Notifications to learn about the number of attacks on your website, certificate expiration, protection rule expiration, and changes of WAF back-to-origin IP addresses or IP addresses used by your website to access WAF.
    • Configure a Web Application Firewall - Domains alarm rule by referring to Configuring Alarm Monitoring Rules to monitor the number of requests, 5XX status codes, number of basic protection times, and number of CC protection times for protected domain names.
  • Backup policy: Save the current DNS, certificate, and back-to-origin configurations for quick rollback in case of a fault.

Routine O&M

During routine protection, you may need to perform the following operations:
  • Viewing Basic Information of a Website: You can view the external protocol type, policy name, alarm page, CNAME, and CNAME IP address for a protected domain name.
  • Updating the Certificate Used for a Website: If a certificate is about to expire or needs to be changed due to revocation or replacement, you need to update the SSL certificate used for the domain name in a timely manner.

    To prevent service interruption caused by certificate expiration, you can configure certificate expiration notifications to receive notifications by email or SMS before the certificate expires. For details, see Enabling Alarm Notifications.

  • Reconnecting a website after its expired ICP filing is renewed: After a domain name is connected to WAF with CNAME records, WAF periodically checks the ICP filing status of the domain name. Once WAF detects that the ICP filing of the domain name has expired, it automatically stops forwarding requests to the domain name. You need to apply for a new ICP filing. After the ICP filing is successful, return to the CNAME access page and connect the domain name to WAF again. (Confirm whether this applies to Huawei Cloud WAF.)
  • Changing the Protection Mode:
    • Bypass WAF: If you need to restore services to the state before they were connected to WAF or check for website exceptions, you can bypass WAF for your service. After this, all requests are directly sent to the origin server and are no longer checked by WAF.
    • Unprotected: If a large number of normal requests are blocked, you can switch WAF protection temporarily. In doing so, WAF only forwards all requests and does not check or log them.
    • Protected: In some scenarios, for example, after manual renewal, you are advised to check the protection status. If the protection status is Unprotected, you need to enable WAF protection again.
  • Batch managing domain names added to WAF through APIs
  • Deleting a Protected Website from WAF: You can delete a protected website from WAF if it no longer requires WAF protection.