Updated on 2023-01-05 GMT+08:00

Creating a Domain Name

This section describes how to create a domain name and connect it to WAF. After connecting a domain name, WAF works 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.

Prerequisites

Login credentials have been obtained.

Domain Configuration Principle

  • Figure 1 shows how WAF works if the web server is using a proxy.
    Figure 1 A proxy configured
    • DNS resolves the domain name to the IP address of a proxy (such as AAD) before your site is moved to WAF. In this case, the traffic passes through the proxy and then the proxy routes the traffic back to the origin server.
    • After your site is moved to WAF, DNS resolves your domain name to the access address of WAF. In this way, the proxy forwards the traffic to WAF. WAF then filters out illegitimate traffic and only routes legitimate traffic back to the origin server.
      1. Change the back-to-source IP address of the proxy to the access address of WAF.
      2. Add a WAF subdomain name and TXT record to the DNS records of your DNS provider.
  • Figure 2 shows how WAF works if the web server does not use a proxy.
    Figure 2 No proxy configured
    • DNS resolves your domain name to the origin server IP address before your site is connected to WAF. Therefore, web visitors can directly access the server.
    • After your website is connected to WAF, DNS resolves your domain name to the CNAME record of WAF. In this way, the traffic passes through WAF. WAF then filters out illegitimate traffic and only routes legitimate traffic back to the origin server.

Procedure

  1. Log in to the management console.
  2. Click in the upper left corner of the management console and select a region or project.
  3. Click Service List at the top of the page and choose Security > Web Application Firewall.
  4. In the navigation pane, choose Domains.
  5. Click Create Domain.
  6. On the Create Domain page, specify required parameters by referring to Table 1.

    Table 1 Parameter description

    Parameter

    Description

    Example Value

    Domain Name

    A domain name to be protected, which can be a single domain name or a wildcard domain name.

    • Single domain name: For example, www.example.com
    • Wildcard domain name
      • If the server IP address of each subdomain name is the same, enter a wildcard domain name. For example, *.example.com.
      • 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

    Wildcard domain name: *.example.com

    Non-standard Port

    Set this parameter only if Non-standard Port is selected.

    • If Client Protocol is HTTP, WAF protects the standard port 80 by default. To protect a non-standard port, select Non-standard Port and then select a value from the Port drop-down list.
    • If Client Protocol is HTTPS, WAF protects the standard port 443 by default. To protect a non-standard port, select Non-standard Port and then select a value from the Port drop-down list.

    For details about non-standard ports supported by WAF, see Web Application Firewall.

    4443

    Server Configuration

    Address configurations of the web server, including Client Protocol, Server Protocol, Server Address, and Server Port.

    • Client Protocol: Type of client protocol. The options are HTTP and HTTPS.
    • Server Protocol: Protocol used by WAF to forward requests to the server. 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.

    • Server Address: IP address (generally the A record before the domain name is connected to WAF) or domain name (generally the CNAME before the domain name is connected to WAF) of the web server that a client accesses
      NOTE:

      WAF cannot check server health. To check server health, use WAF along with Elastic Load Balance (ELB). After a load balancer is configured, use the EIP bound to the load balancer as your origin server IP address and point this IP address to your WAF instance.

    • Server Port: Port number used by the web server

    Client Protocol: HTTPS

    Server Protocol: HTTP

    Server Address: XXX.XXX.1.1

    Server Port: 80

    Certificate Name

    If Client Protocol is HTTPS, select an existing certificate or upload a new certificate. For details about how to upload a new certificate, see 7.

    None

  7. Upload a new certificate if Client Protocol is HTTPS.

    1. Click Upload Certificate. In the displayed Upload Certificate dialog box, enter the certificate name and paste the certificate file and private key to the corresponding text boxes.
      Currently, only .pem certificates are supported. If the certificate is not in .pem format, convert it into a .pem certificate by referring to Table 2 before uploading.
      Table 2 Certificate conversion commands

      Format

      Usage (Using OpenSSL)

      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 cert.key:

        openssl pkcs12 -in cert.pfx -nocerts -out cert.key -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

      1. 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

      2. 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. As an example, run the following command to convert cert.cer into cert.pem:

        openssl x509 -inform der -in cert.cer -out cert.pem

    2. Click OK.

  8. Set Proxy Configured. The default value is No.

    If a proxy is deployed before WAF on your website, the WAF working mode cannot be switched to Bypassed.

    • If your website is using a proxy such as Advanced Anti-DDoS (AAD), Content Delivery Network (CDN), or any other cloud acceleration service, select Yes so that the WAF security policies take effect on the origin server IP address. If this parameter is No, WAF cannot obtain the real IP address requested by a web visitor.

      If a proxy such as CDN is used, WAF obtains the real source IP address of a client from the HTTP Header X-Forwarded-For by default. If the proxy does not use X-Forwarded-For to identify the real source IP address of a client, click next to X-Forwarded-For in the row of Source IP Header. In the displayed dialog box, select an existing source IP header or select Custom and enter a source IP header.

    • If your website does not use a proxy, select No.

  9. Click Create Now. In the upper right corner of the page, if Domain created successfully is displayed, the domain name is created.

    If you do not want to connect the domain name to WAF in this step, click Next. Then click Finish. DNS is displayed as Unconfigured. Later, you can refer to Connecting a Domain Name to finish domain connection.

    • If a proxy such as CDN or AAD is used, you need to configure the back-to-source IP address, subdomain name, and TXT record.
      1. Configure the back-to-source IP address of the proxy on the website.

        For example, change the back-to-source IP address of CDN or AAD to the WAF IP address.

      2. Configure Subdomain Name and TXT Record.

        Add a subdomain name and TXT record to the DNS records of your DNS provider.

      The high availability of our system, which is based on multi-AZ deployments to support both active-active and disaster recovery, relies on the WAF CNAME record. Do not use a fixed IP address to access services. Otherwise, service disaster recovery reliability will be affected.

    • If no proxy is used, the CNAME record must be configured.
      1. Go to your DNS provider and configure the CNAME record. For details, contact your DNS provider.

        The high availability of our system, which is based on multi-AZ deployments to support both active-active and disaster recovery, relies on the WAF CNAME record. Do not use a fixed IP address to access services. Otherwise, service disaster recovery reliability will be affected.

        1. Do not modify the hosts file. Add the CNAME record directly to the DNS records of your DNS provider.
        2. Do not use the A record to replace the CNAME record.

        The CNAME binding method of some common DNS providers is listed for your reference. If the following configuration is inconsistent with the actual configuration, rely on information provided by the DNS providers.

        1. Log in to the management console of the DNS provider.
        2. Go to the domain resolution record page.
        3. Set the CNAME resolution record.
          • Set the record type to CNAME.
          • Generally, enter the domain name prefix in the host record. For example, if the protected domain name is admin.demo.com, enter admin in the host record.
          • The record value is the CNAME generated by WAF.
          • Resolution line: keep the default value TTL.
        4. Click Save.

        The preceding resolution methods are provided by third parties. This document does not control or assume responsibility for any third party content, including but not limited to its accuracy, compatibility, reliability, availability, legitimacy, appropriateness, performance, non-infringement, or status update, unless otherwise specified in this document.

      2. Verify that the CNAME has been configured.
        1. In Windows, choose Start > Run. Then enter cmd and press Enter.
        2. Run the following command to query the CNAME. If the configured CNAME is displayed, the configuration is successful.

          nslookup www.domain.com

  10. After the domain name is connected to WAF, click Next.
  11. Click Finish.

    You can view the DNS status and mode of the domain name in the domain list.

    • If your web server is using other firewalls, disable the firewalls or whitelist the WAF IP address ranges.
    • If your web server is using personal security software, replace it with enterprise security software and whitelist the WAF IP address ranges.
    • If a domain name has been connected to WAF, DNS should be Normal. If DNS is Unconfigured, choose More > Check DNS in the Operation column of the target domain name to check the DNS status. If the problem persists, perform domain connection again by referring to What Should I Do If the DNS Status Is Unconfigured?
    • After a domain name is created, WAF protection is enabled by default. The mode of Basic Web Protection is Log only (detected attacks are only logged but not blocked.). WAF creates a CC attack protection rule for the domain name by default. The rule can be modified but cannot be deleted. Rate Limit in the rule is 500 requests/5 seconds by default and it can be adjusted up to 10,000 requests/5 seconds. If you want a higher rate limit than the maximum value, contact the administrator.

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 mode.

    Client Protocol and Server Protocol are set to HTTP.

    This configuration allows web visitors to access your website over HTTP only. If they access over HTTPS, they receive the 302 Found code and are redirected to http://www.example.com.

  • HTTPS mode. This configuration allows web visitors to access your website over HTTPS only. If they access over HTTP, they are redirected to https://www.example.com.
    • If web visitors access your website over HTTPS, the website returns a successful response.
    • If web visitors access your website over HTTP, they receive the 302 Found code and are directed to https://www.example.com.
  • HTTP and HTTPS mode.

    Add two server configurations. One uses HTTP for Client Protocol and Server Protocol, and the other uses HTTPS for Client Protocol and Server Protocol.

    • 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/HTTP mode.

    Client Protocol is set to HTTPS and Server Protocol is set to HTTP.

    If web visitors access your website over HTTPS, WAF forwards the requests to your origin server over HTTP.