Help Center> Web Application Firewall> User Guide> Adding a Website to WAF (ELB Mode)> Step 3: Whitelisting Back-to-Source IP Addresses of Your Load-Balancing WAF Instances

Step 3: Whitelisting Back-to-Source IP Addresses of Your Load-Balancing WAF Instances

To let your load-balancing WAF instances take effect, configure ACL rules on the origin server to trust only the back-to-source IP addresses of all your load-balancing WAF instances. This prevents hackers from attacking the origin server through the server IP addresses.

ACL rules must be configured on the origin server to whitelist WAF back-to-source IP addresses. Otherwise, your website visitors will frequently receive 502 or 504 error code after your website is connected to WAF in ELB mode.

Why Do I Need to Whitelist the WAF Back-to-Source IP Addresses?

After your website domain name is connected to WAF in ELB mode, all web requests are forwarded to WAF and WAF then forwards the normal traffic to the origin server. In this way, the origin server only communicates with WAF back-to-source IP addresses. By doing so, WAF protects the origin server from being attacked even if the server IP address is exposed to hackers accidentally. In ELB mode, the WAF back-to-source IP addresses are the subnet IP addresses of the load-balancing WAF instances.

The security software on the origin server may most likely block the back-to-source IP addresses of load-balancing WAF instances as malicious ones. Once they are blocked, the origin server will deny all WAF requests. As a result, your website may become unavailable or respond very slowly. Therefore, in ELB mode, ACL rules must be configured on the origin server to trust only the subnet IP addresses of your load-balancing WAF instances.

Prerequisites

Your website has been connected to WAF in ELB mode.

If you have enabled enterprise projects, you can select your enterprise project from the Enterprise Project drop-down list and whitelist back-to-source IP addresses of your load-balancing WAF instances in the project.

Pointing Traffic to an ECS Hosting Your Website

If your origin server is deployed on a HUAWEI CLOUD ECS, perform the following steps to configure a security group rule to allow only the back-to-source IP address of your load-balancing WAF instance to access the origin server.

  1. Log in to the management console.
  2. Go to the Dedicated Engine page by following the steps shown in Figure 1.

    Figure 1 Access to the dedicated engine page

  3. In the Subnet IP Address column, obtain the IP address of each load-balancing WAF instance under your account. Load-balancing WAF instances are listed in the dedicated engine list. Figure 2 shows an example.

    Figure 2 Subnet IP Address of a load-balancing WAF instance

  4. Click in the upper left corner of the page and choose Compute > Elastic Cloud Server.
  5. Locate the row containing the ECS hosting your website. In the Name/ID column, click the ECS name to go to the ECS details page.
  6. Click the Security Groups tab. Then, click Change Security Group.
  7. In the Change Security Group dialog box displayed, select a security group or create a security group.
  8. Click the security group name to view the details.
  9. Click the Inbound Rules tab and click Add Rule. Then, specify parameters in the Add Inbound Rule dialog box. For details, see Table 1. Figure 3 shows an example.

    Figure 3 Add Inbound Rule
    Table 1 Inbound rule parameters

    Parameter

    Description

    Protocol & Port

    Protocol and port for which the security group rule takes effect. If you select TCP (Custom ports), enter the origin server port number in the text box below the TCP box.

    Source

    Subnet IP address of each load-balancing WAF instance you obtain in Step 3. Configure an inbound rule for each IP address.

    NOTE:

    An inbound rule can contain only one IP address. To configure an inbound rule for each IP address, click Add Rule to add more rules. A maximum of 10 rules can be configured.

  10. Click OK.

    Now, the security group allows all inbound traffic from the back-to-source IP addresses of all your load-balancing WAF instances.

    To check whether the configuration takes effect, use the Telnet tool to check whether a connection to the origin server service port bound to the IP address protected by WAF is established.

    For example, run the following command to check whether the connection to the origin server service port 443 bound to the IP address protected by WAF is established. If the connection cannot be established over the service port but the website is still accessible, the security group inbound rules take effect.

    Telnet Origin server IP address443

Pointing Traffic to a Load Balancer

If your origin server uses HUAWEI CLOUD ELB to distribute traffic, perform the following steps to configure an access control policy to allow only the IP addresses of the load-balancing WAF instances to access the origin server:

  1. Log in to the management console.
  2. Go to the Dedicated Engine page by following the steps shown in Figure 4.

    Figure 4 Access to the dedicated engine page

  3. In the Subnet IP Address column, obtain the IP address of each load-balancing WAF instance under your account. Load-balancing WAF instances are listed in the dedicated engine list. Figure 5 shows an example.

    Figure 5 Subnet IP Address of a load-balancing WAF instance

  4. Click in the upper left corner of the page and choose Networking > Elastic Load Balance.
  5. Locate the row containing the load balancer configured for your dedicated WAF instance and click the load balancer name in the Name column.
  6. On the displayed details page, click the Listeners tab and then click Configure Access Control. Figure 6 shows an example.

    Figure 6 Configuring Access Control

  7. In the displayed dialog box, select Whitelist for Access Policy. Click Create IP Address Group and add the load-balancing WAF instance IP addresses obtained in Step 3 to it. Then, select the created IP address group for IP Address Group. Figure 7 shows an example.

    Figure 7 Configuring whitelist access control

    Click Create IP Address Group and add the load-balancing WAF instance IP addresses to the group being created.

  8. Click OK.

    Now, the access control policy allows all inbound traffic from the back-to-source IP addresses of your load-balancing WAF instances.

    To check whether the configuration takes effect, use the Telnet tool to check whether a connection to the origin server service port bound to the IP address protected by WAF is established.

    For example, run the following command to check whether the connection to the origin server service port 443 bound to the IP address protected by WAF is established. If the connection cannot be established over the service port but the website is still accessible, the security group inbound rules take effect.

    Telnet Origin server IP address443