Help Center/ Web Application Firewall/ User Guide/ Connecting a Website to WAF/ Connecting Your Website to WAF (Cloud Mode - Load Balancer Access)
Updated on 2024-11-05 GMT+08:00

Connecting Your Website to WAF (Cloud Mode - Load Balancer Access)

If your service servers are deployed on Huawei Cloud, you can connect your web services to your WAF instance in cloud load balancer access mode.

You can select Cloud Mode - Load balancer when connecting a website to WAF only when the website has used a dedicated load balancer to forward traffic. In this mode, WAF works in out-of-path mode and does not forward traffic. Before using this mode, configure a dedicated load balancer first. .

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

Solution Overview

In cloud load balancer access mode, WAF is integrated into the load balancer gateway through an SDK modular. After your website is connected to WAF, the ELB load balancer mirrors the website traffic to WAF. WAF checks the mirrored traffic and synchronizes the check result to the load balancer. The load balancer determines whether to forward client requests to the origin server based on the check result it receives. In this method, WAF does not forward traffic. This eliminates compatibility and stability issues that might be caused by additional-layer of traffic forwarding.

Figure 1 shows the request forwarding process after a domain name is connected to WAF.

Figure 1 Website access diagram
The traffic forwarding 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. The client accesses the ELB load balancer over its EIP.
  4. The ELB load balancer mirrors traffic to WAF.
  5. WAF checks the traffic and synchronizes the check result to the ELB load balancer.
  6. The ELB load balancer determines whether to forward traffic to the origin server based on check result WAF sends to it.

Prerequisites

  • You have purchased a cloud WAF instance and understood details about how to connect a website to WAF.
    • To use cloud load balancer WAF, you need to submit a service ticket to enable it for you first. Cloud load balancer WAF is available in some regions. For details, see Functions.
    • If you want to use the load balancer access mode, make sure you are using standard, professional, or platinum cloud WAF. When you are using cloud WAF, the quotas for the domain name, QPS, and rule expansion packages are shared between the cloud load balancer and cloud CNAME access modes.
  • You have purchased a dedicated load balancer with Specifications set to Application load balancing (HTTP/HTTPS). For more details, see Creating a Dedicated Load Balancer. Note that you should use the same account to buy the load balancer and dedicated WAF.

Connecting Your Website to WAF (Cloud Mode - Load balancer Access Mode)

  1. Create a dedicated load balancer.

    • Specifications: Select Application load balancing (HTTP/HTTPS) .
    • Set other parameters based on your service requirements.

  2. Add a listener to the load balancer created in 1. For details, see Adding an HTTP Listener or Adding an HTTPS Listener.
  3. Create a backend server group.

    • Load Balancer: Select Associate existing and select the load balancer created in 1 from the drop-down list.
    • Configure the server address of the website you plan to add to WAF in 5 as backend server.

  4. Run the following command to check the service connectivity:

    curl -kv -H "Host: {Origin server domain name}" {protocol of the listener}://{IP address of the ELB load balancer}:{port of the listener}

    If status code 200 is returned, the service has been connected.

  5. Configure the websites for which you want WAF to check the traffic.

    1. Click in the upper left corner and choose Web Application Firewall under Security & Compliance.
    2. In the navigation pane on the left, choose Website Settings.
    3. In the upper left corner of the website list, click Add Website.
    4. Select Cloud Mode - Load balancer and click Configure Now.
    5. On the displayed page, configure basic settings by referring to Table 1.
      Figure 2 Configuring basic settings of a website
      Table 1 Parameter description

      Parameter

      Description

      Example Value

      ELB (Load Balancer)

      Select the load balancer created in 1 and ensure that the server address of the protected website has been added to the load balancer.

      elb-waf-test

      ELB Listener

      Listener configured for the selected ELB load balancer.

      • All listeners
      • Specific listener

      All listeners

      Website Name

      (Optional) You can specify a name for your website.

      None

      Domain Name

      Set this parameter to the domain name or IP address (public or private IP address) you want to protect. Make sure that the domain name has been resolved to the EIP of the load balancer created in 1.

      Domain name: Single domain names or wildcard domain names are supported.
      • Single domain name: Enter a 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, 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.
        • Wildcard domain name* can be added.
      NOTE:

      WAF can protect both public and private IP addresses. If a private IP address is used, ensure that the corresponding network path is accessible so that WAF can correctly monitor and filter traffic.

      Single domain name: www.example.com

      Wildcard domain name: *.example.com

      IP Address:

      XXX.XXX.1.1

      Website Remarks

      (Optional) You can enter a description for your website.

      -

      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

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

      NOTE:
      • Log only: WAF only logs detected attacks instead of blocking them.
      • Only the professional and platinum editions allow you to specify a custom policy for Policy.

      System-generated policy

    6. Click OK.

      You can view the added websites in the protected website list.

Follow-up Operations