Step 1: Adding a Domain Name to WAF (Cloud Mode)
This topic describes how to add a domain name to WAF so that the website traffic can pass through WAF. After you connect a website domain name to your WAF instance, WAF works as a reverse proxy between the client and the server. The real IP address of the server is hidden and only the IP address of WAF is visible to web visitors.
If you have enabled enterprise projects, you can select your enterprise project from the Enterprise Project drop-down list and add domain names of websites to be protected in the project.
Prerequisites
- You have purchased a cloud WAF instance.
- The domain name has been registered with the ICP license and has not been added to WAF.
Specification Limitations
- Only the professional (former enterprise edition) and platinum (original premium edition) editions can protect websites that use IPv6 addresses.
Currently, IPv4/IPv6 dual stack and NAT64 are supported only in East China and North China regions.
- After your website is connected to WAF, the file visitors can upload each time cannot exceed 512 MB.
- The detection edition does not support wildcard domain names.
Constraints
- Domain names added by an IAM user can be viewed by the account that creates the IAM user, but domain names added by an account cannot be viewed by IAM users created under the account.
- A domain name cannot be added to WAF cloud mode repeatedly.
Each combination of a domain name and a port is counted towards the domain name quota of the WAF edition you are using. For example, www.example.com:8080 and www.example.com:8081 use two domain names of the quota. If you want to protect web services over multiple ports with the same domain name, add the domain name and each port to WAF.
- You can enter a multi-level single domain name (for example, top-level domain name example.com and level-2 domain name www.example.com) or a wildcard domain name (*.example.com).
- Wildcard domain names cannot contain underscores (_).
- The following are the rules for adding wildcards to domain names:
- If the server IP address of each subdomain name is the same, enter a wildcard domain name to be protected. For example, if the subdomain names a.example.com, b.example.com, and c.example.com have the same server IP address, you can add the 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.
- WAF does not support user-defined HTTP headers for protected domain names.
- Only the domain names that have been registered with ICP licenses can be added to WAF.
- A CNAME record is generated based on a domain name. For the same domain name, the CNAME records are the same.
- Only .pem certificates can be used in WAF.
- 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.
- WAF supports the WebSocket protocol, which is enabled by default.
- WebSocket request inspection is enabled by default if Client Protocol is set to HTTP.
- WebSockets request inspection is enabled by default if Client Protocol is set to HTTPS.
- If you are using WAF detection edition or standard edition (former professional edition), only system-generated policy can be selected for Configure Policy.
Impact on the System
If a non-standard port 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?
Collecting Domain Name Information
Before adding a domain name, obtain the information listed in Table 1.
| Information | Parameter | Description | Example Value |
|---|---|---|---|
| Whether a proxy is used for the domain name | N/A | Check whether advanced anti-DDoS or CDN are deployed in front of WAF. | N/A |
| Parameters | Domain Name | The domain name is used by visitors to access your website. A domain name consists of letters separated by dots (.). It is a human readable address that maps to the machine readable IP address of your server. | www.example.com |
| Standard/Non-standard Port | The service port corresponding to the domain name of the website you want to protect.
| 80 | |
| Client Protocol | Protocol used by a client (for example, a browser) to access a website. WAF supports HTTP and HTTPS. | HTTP | |
| Server Protocol | Protocol used by WAF to forward requests to the client (such as a browser). The options are HTTP and HTTPS. | HTTP | |
| Server Address | Public IP address or domain name of the origin server for a client (such as a browser) to access. Generally, a public IP address maps to the A record of the domain name configured on the DNS, and a domain name to the CNAME record. | XXX.XXX.1.1 | |
| (Optional) Certificate | - | If you set Client Protocol to HTTPS, you are required to configure a certificate on WAF and associate the certificate with the domain name. NOTICE: Only .pem certificates can be used in WAF. If your certificate is not in PEM format, convert the certificate format by referring to How Do I Convert a Non-PEM Certificate to a PEM One? | None |
Procedure
- Log in to the management console.
- Go to the Website Settings page by following the steps shown in Figure 1.
- In the upper left corner of the website list, click Add Website.
- Select Cloud Mode. Enter the domain name in the Domain Name text box and click OK. Figure 2 Domain Name
You can enter a multi-level single domain name (for example, top-level domain name example.com and level-2 domain name www.example.com) and wildcard domain name *.example.com).
- The detection edition does not support wildcard domain names.
- Wildcard domain names cannot contain underscores (_).
- The following are the rules for adding wildcards to domain names:
- If the server IP address of each subdomain name is the same, enter a wildcard domain name to be protected. For example, if the subdomain names a.example.com, b.example.com, and c.example.com have the same server IP address, you can add the 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.
If your domain name is hosted on HUAWEI CLOUD, you can click Quick Add. In the Select Domain Name dialog box displayed, select the domain name you want to protect and click OK. The hosted domain name is automatically added.
- Configure Domain Name and other parameters by referring to Table 2. Figure 3 shows an example.
Table 2 Parameter description Parameter
Description
Example Value
Website Name
Name of the website you want to protect
-
Domain Name
The domain name of a website to be protected. It can be a single domain name or a wildcard domain name.
- Single domain name: Enter a single domain name.
- Wildcard domain name: Enter a wildcard domain name of the website to be protected. Wildcard domain names cannot contain underscores (_).
NOTE:- The detection edition does not support wildcard domain names.
- If the server IP address of each subdomain name is the same, enter a wildcard domain name. For example, if the subdomain names a.example.com, b.example.com, and c.example.com have the same server IP address, you can add the 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.
Single domain name: www.example.com
Top-level domain name: example.com
Wildcard domain name: *.example.com
Non-standard Port
Set this parameter only if Non-standard Port is selected. For details, see Configuration Example 1: Protecting Traffic to the Same Standard Port with Different Origin Server IP Addresses Assigned.
- If you set Client Protocol to HTTP, WAF protects services on the standard port 80 by default. If you set Client Protocol to HTTPS, WAF protects services of the standard port 443 by default.
- To configure a port other than ports 80 and 443, select Non-standard Port and select a non-standard port from the Port drop-down list.
For details, see Which Non-Standard Ports Does WAF Support?
NOTE:If a non-standard port 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?
81
Website Remarks
A brief description of the website
-
Server Configuration
Address configurations of the web server, including Client Protocol, Server Protocol, Server Address, and Server Port.
- Client Protocol: protocol used by a client to access a server. The options are HTTP and HTTPS.
- Server Protocol: protocol used by WAF to forward client requests. The options are HTTP and HTTPS. NOTE:
- For details about configuring Client Protocol and Server Protocol, see Rules for Configuring Client Protocol and Server Protocol.
- WAF supports the Web Socket protocol, which is enabled by default.
- Server Address: public IP address (generally corresponding to the A record of the domain name configured on the DNS) or domain name (generally corresponding to the CNAME of the domain name configured on the DNS) of the web server that a client accesses. The following IP address formats are supported:
- IPv4 address, for example, XX.XXX.1.1
- IPv6 address, for example, 1050:0:0:0:5:600:300c:326b
NOTICE:IPv6 protection is available in the professional (former enterprise) and platinum (former premium) editions only. Currently, IPv4/IPv6 dual stack and NAT64 are supported only in East China and North China regions.
- Server Port: service port of the server which the WAF instance forwards client requests to.
Client Protocol: HTTP
Server Protocol: HTTP
Server Address: IPv4 XXX.XXX.1.1
Server Port: 80
Certificate Name
If you set Client Protocol to HTTPS, a certificate is required. You can select a created certificate or import a certificate. For details about how to import a certificate, see Step 6.
The imported certificates are listed on the Certificates page. For more details, see Uploading a Certificate.
Additionally, you can buy a certificate on the SCM console and push it to WAF. For details about how to push an SSL certificate in SCM to WAF, see Pushing Certificates to Other Services on HUAWEI CLOUD.
NOTICE:- Only .pem certificates can be used in WAF. If the certificate is not in .pem format, convert it into a .pem certificate by referring to Table 3 before uploading the certificate.
- 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.
- 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.
- Each domain name must have a certificate associated. A wildcard domain name can only use a wildcard domain certificate. If you only have single-domain certificates, add domain names one by one in WAF.
None
- (Optional) Import a certificate.
If you set Client Protocol to HTTPS, a certificate is required. Perform the following steps to import a certificate.
- Click Import New Certificate. In the displayed Import New Certificate dialog box, enter the certificate name and paste the certificate file and private key to the corresponding text boxes. Figure 4 shows an example.
WAF encrypts and saves the private key to keep it safe.
Only .pem certificates can be used in WAF. If the certificate is not in .pem format, convert it into a .pem certificate locally by referring to Table 3 before uploading.Table 3 Certificate conversion commands Format
Conversion Method
CER/CRT
Rename the cert.crt certificate file to cert.pem.
PFX
- Obtain a private key. For example, run the following command to convert cert.pfx into key.pem:
openssl pkcs12 -in cert.pfx -nocerts -out key.pem -nodes
- Obtain a certificate. For example, run the following command to convert cert.pfx into cert.pem:
openssl pkcs12 -in cert.pfx -nokeys -out cert.pem
P7B
- Convert a certificate. For example, run the following command to convert cert.p7b into cert.cer:
openssl pkcs7 -print_certs -in cert.p7b -out cert.cer
- Rename certificate file cert.cer to cert.pem.
DER
- Obtain a private key. For example, run the following command to convert privatekey.der into privatekey.pem:
openssl rsa -inform DER -outform PEM -in privatekey.der -out privatekey.pem
- Obtain a certificate. For example, run the following command to convert cert.cer into cert.pem:
openssl x509 -inform der -in cert.cer -out cert.pem
- Before running an OpenSSL command, ensure that the OpenSSL tool has been installed on the local host.
- If your local PC runs a Windows operating system, go to the command line interface (CLI) and then run the certificate conversion command.
- Obtain a private key. For example, run the following command to convert cert.pfx into key.pem:
- Click OK.
- Click Import New Certificate. In the displayed Import New Certificate dialog box, enter the certificate name and paste the certificate file and private key to the corresponding text boxes. Figure 4 shows an example.
- Set Proxy Configured. No is selected by default.
- If a proxy is deployed before WAF on your website, the WAF working mode cannot be switched to Bypassed. For more details, see Switching WAF Working Mode.
- If a website does not use any proxy but you select Yes for Proxy Configured, WAF trusts the X-Forwarded-For field in the HTTP request header when obtaining the real source IP address. Therefore, your business is not affected.
- A proxy such as advanced anti-DDoS, Content Delivery Network (CDN), or any other cloud acceleration service used: Select Yes so that WAF security policies take effect on the real source IP address. If you select No, WAF cannot obtain the real IP address of a request from a web visitor.
- No proxy used: Select No.
- Specify Configure Policy. By default, system-generated policy is selected. You can select custom rules. For details, see Table 4.
If you are using WAF detection edition or standard edition (former professional edition), only system-generated policy is available.
You can select a policy you configured. You can also customize rules after the domain name is connected to WAF.
Table 4 System-generated policies Edition
Policy
Description
Standard edition (former professional edition) and detection edition
Basic web protection (Log only mode and common checks)
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.
Professional (former enterprise) and platinum (former premium) editions
Basic web protection (Log only mode and common checks)
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 (Log only mode and Scanner feature)
WAF only logs web scanning tasks, such as vulnerability scanning and virus scanning, such as crawling behavior of OpenVAS and Nmap.
Log only: WAF only logs detected attack events instead of blocking them.
- Click Next.
You are advised to skip this step by clicking Next and then Finish. Then, connect the domain name to WAF later by referring to Step 2: Testing WAF and Step 3: Routing Website Traffic to WAF.
A CNAME record is generated based on a domain name. For the same domain name, the CNAME records are the same.
- Click Next and then Finish.
You can then view the access status and working mode for the added domain name on the Website Settings page.
Figure 5 Added Domain Name
- To configure a protection policy for the website, click Configure Policy.
- To add more websites to be protected, click Add Another Domain Name.
- To view the added website, close the dialog box.
- If your server uses other network firewalls, disable these network firewalls or add the WAF IP address range to the IP address whitelist of these network firewalls. Otherwise, these firewalls may regard the WAF IP address as a malicious IP address. For details, see How Do I Whitelist WAF Back-to-Source IP Address Range?
- If your web server is using personal security software, replace it with enterprise security software and whitelist the WAF IP address ranges.
Verification
- By default, WAF detects the Access Status of each protected domain name on an hourly basis.
- Generally, if you have performed domain connection and Access Status is Accessible, the domain name is connected to WAF.
If a domain name has been connected to WAF but Access Status is Inaccessible, click
to refresh. If Access Status is still Inaccessible, connect the domain name to WAF again by referring to Step 3: Routing Website Traffic to WAF.
Other Operations
Configuration Example 1: Protecting Traffic to the Same Standard Port with Different Origin Server IP Addresses Assigned
- Deselect Non-standard Port.
- Select HTTP or HTTPS for Client Protocol. Figure 6 and Figure 7 show standard port configurations when the client protocol is HTTP or HTTPS.
If Client Protocol is set to HTTPS, a certificate is required.
- Your website visitors can access the website without adding a port number to the end of the domain name. For example, enter http://www.example.com in the address box of the browser to access the website.
Configuration Example 1: Protecting Traffic to a Non-Standard Port with Different Origin Server IP Addresses Assigned
- Select Non-standard Port and select a non-standard port to be protected from the Port drop-down list. For details about the non-standard ports supported by WAF, see Which Non-Standard Ports Does WAF Support?
- Select HTTP or HTTPS for Client Protocol for all server ports. Figure 8 and Figure 9 show the configuration of non-standard HTTP or HTTPS port, respectively.
If Client Protocol is set to HTTPS, a certificate is required.
- Visitors must add the configured non-standard port to the domain name when they access your website. Otherwise, error 404 is returned. If the non-standard port is 8080, enter http://www.example.com:8080 in the address box of the browser.
Configuration Example 3: Protecting Different Service Ports
Rules for Configuring Client Protocol and Server Protocol
WAF provides various protocol types. If your website is www.example.com, WAF provides the following four access modes:
- HTTP method (Figure 12)
This configuration allows web visitors to access http://www.example.com over HTTP only. If they access it over HTTPS, they will receive the 302 Found code and be redirected to http://www.example.com.
- HTTPS method. This configuration allows web visitors to access your website over HTTPS only. If they access it over HTTP, they are redirected to the HTTPS URL. Figure 13 shows an example.
- If web visitors access your website over HTTPS, the website returns a successful response.
- If web visitors access http://www.example.com over HTTP, they will receive the 302 Found code and are directed to https://www.example.com.
- HTTP/HTTPS forwarding method. Figure 14 shows an example.
- If web visitors access your website over HTTP, the website returns a successful response but no communication between the browser and website is encrypted.
- If web visitors access your website over HTTPS, the website returns a successful response and all communications between the browser and website are encrypted.
- HTTPS offloading by WAF. Figure 15 shows an example.
If web visitors access your website over HTTPS, WAF forwards the requests to your origin server over HTTP.
Last Article: Connection Process (Cloud Mode)
Next Article: Step 2: Testing WAF













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