Updated on 2024-04-17 GMT+08:00

Step 1: Add a Website to WAF (Dedicated Mode)

If your service servers are deployed on Huawei Cloud, you can use dedicated WAF instances to protect your website services as long as your website has domain names or IP addresses.

If you have enabled enterprise projects, you can select your enterprise project from the Enterprise Project drop-down list and add websites to be protected in the project.

Prerequisites

You have purchased a dedicated WAF instance.

Constraints

  • A dedicated Elastic Load Balance (ELB) load balancer has been used to distribute workloads for the website you want to add to WAF. For details about load balancer types, see Differences Between Dedicated and Shared Load Balancers.

    Dedicated WAF instances issued before April 2023 cannot be used with dedicated network load balancers. If you use a dedicated network load balancer (TCP/UDP), ensure that your dedicated WAF instance has been upgraded to the latest version (issued after April 2023). For details, see Dedicated Engine Version Iteration.

  • If a layer-7 proxy server, such as CDN or cloud acceleration, is used before WAF, you need to select Layer-7 proxy for Proxy Configured. By doing this, WAF can obtain real client access IP addresses from the configured header field. For details, see Configuring a Traffic Identifier for a Known Attack Source.
  • Certificate restrictions:
    • 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.
    • Only accounts with the SCM Administrator and SCM FullAccess permissions can select SCM certificates.
  • If wildcard (*) is added to WAF, only non-standard ports other than 80 and 443 can be protected.

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 in the upper left corner and choose Web Application Firewall under Security & Compliance.
  1. In the navigation pane, choose Website Settings.
  2. In the upper left corner of the website list, click Add Website.
  3. Select Dedicated and click OK.
  4. Provide the domain name details.

    • Website Name: (Optional) You can customize the website name.
    • Protected Object: Enter the domain name of a website you want WAF to protect. You can enter a single domain name or a wildcard domain name.
      • The wildcard * can be added to WAF to let WAF protect any domain names. If wildcard (*) is added to WAF, only non-standard ports other than 80 and 443 can be protected.
      • 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.
    • Website Remarks: (Optional) You can provide remarks about your website if you want.
    Figure 1 Configuring domain name details

  5. Configure the origin server by referring to Table 1.

    Figure 2 Origin Server Settings
    Table 1 Parameter description

    Parameter

    Description

    Example Value

    Protected Port

    Select the port type that you want WAF to protect from the drop-down list.

    To protect port 80 or 443, select Standard port from the drop-down list.

    For details about ports supported by WAF, see Ports Supported by WAF.

    NOTE:

    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?

    81

    Server Configuration

    Address of the web server. The configuration contains the Client Protocol, Server protocol, VPC, 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.
    • VPC: Select the VPC to which the dedicated WAF instance belongs.
      NOTE:

      To implement active-active services and prevent single points of failure (SPOFs), it is recommended that at least two WAF instances be configured in the same VPC.

    • Server Address: private IP address of the website server.

      Log in to the ECS or ELB console and view the private IP address of the server in the instance list.

      NOTE:

      The origin server address cannot be the same as that of the protected object.

      The following IP address formats are supported:
      • IPv4, for example, XX.XXX.1.1
      • IPv6, for example, fe80:0000:0000:0000:0000:0000:0000:0000
    • Server Port: service port of the server to which the dedicated WAF instance forwards client requests.

    Client Protocol: HTTP

    Server Protocol: HTTP

    Server Address: XXX.XXX.1.1

    Server Port: 80

    Certificate Name

    If you set Client Protocol to HTTPS, an SSL certificate is required. You can select an existing certificate or import an external certificate. For details about how to import a certificate, see Importing a New Certificate.

    The newly imported certificates will be listed on the Certificates page. For more details, see Uploading a Certificate.

    Alternatively, you can buy a certificate on the CCM console and push it to WAF. For details about how to push an SSL certificate in CCM to WAF, see Pushing an SSL Certificate to Other Cloud Services.

    NOTICE:
    • Only .pem certificates can be used in WAF. If the certificate is not in .pem format, convert it into .pem by referring to Importing a New Certificate 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.

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

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

    --

  6. Configure the advanced settings.

    Figure 3 Advanced settings
    • Configure Proxy Configured.
      • Layer-7 proxy: Web proxy products for layer-7 request forwarding are used, products such as anti-DDoS, CDN, and other cloud acceleration services.
      • Layer-4 proxy: Web proxy products for layer-4 forwarding are used, products such as anti-DDoS.
      • No proxy: No proxy products are deployed in front of WAF.

      If you select Layer-7 proxy, WAF obtains the actual access IP address from the configured header field. For details, see Configuring a Traffic Identifier for a Known Attack Source.

    • Policy: The System-generated policy is selected by default. You can select a policy you configured before. You can also customize rules after the domain name is connected to WAF.

      System-generated policies include:

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

  7. Click OK.

    To enable WAF protection, there are still several steps, including configuring a load balancer, binding an EIP to the load balancer, and whitelisting WAF IP addresses. You can click Later in this step. Then, follow the instructions and finish those steps by referring to Step 2: Configure a Load Balancer for WAF, Step 3: Bind an EIP to a Load Balancer, and Step 4: Whitelist Back-to-Source IP Addresses of Dedicated WAF Instances.

Verification

The initial Access Status of a website is Inaccessible. After you configure a load balancer and bind an EIP to the load balancer for your website, when a request reaches the WAF dedicated instance, the access status automatically changes to Accessible.

Importing a New Certificate

If you set Client Protocol to HTTPS, an SSL certificate is required. You can perform the following steps to import a new certificate.

  1. Click Import New Certificate. In the displayed dialog box, enter a certificate name, and copy and paste the certificate file and private key to the corresponding text boxes.
    Figure 4 Import New Certificate

    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 .pem locally by referring to Table 2 before uploading it.
    Table 2 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

    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. 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.
  2. Click Confirm.