Updated on 2024-03-14 GMT+08:00

Step 4: Whitelist IP Addresses of Dedicated WAF Instances

To let your dedicated WAF instances take effect, configure ACL rules on the origin server to trust only the back-to-source IP addresses of all your dedicated 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.

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

In dedicated mode, website traffic is pointed to the load balancer configured for your dedicated WAF instances and then to dedicated WAF instances. The latter will filter out malicious traffic and route only 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 IP address from being attacked. In dedicated mode, the WAF back-to-source IP addresses are the subnet IP addresses of the dedicated WAF instances.

The security software on the origin server may most likely regard WAF back-to-source IP addresses as malicious and block them. Once they are blocked, the origin server will deny all WAF requests. Your website may become unavailable or respond very slowly. So, you need to configure ACL rules on the origin server to trust only the subnet IP addresses of your dedicated WAF instances.

Prerequisites

Your website has been connected to your dedicated WAF instances.

Pointing Traffic to an ECS Hosting Your Website

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

  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 Security > Web Application Firewall to go to the Dashboard page.
  4. In the IP Address column, obtain the IP address of each dedicated WAF instance under your account.
  5. Click in the upper left corner of the page and choose Compute > Elastic Cloud Server.
  6. 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.
  7. Click the Security Groups tab. Then, click Change Security Group.
  8. In the Change Security Group dialog box displayed, select a security group or create a security group and click OK.
  9. Click the security group ID and view the details.
  10. Click the Inbound Rules tab and click Add Rule. Then, specify parameters in the Add Inbound Rule dialog box. For details, see Table 1.

    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 dedicated WAF instance you obtain in Step 4. 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.

  11. Click OK.

    Now, the security group allows all inbound traffic from the back-to-source IP addresses of all your dedicated 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 ELB to distribute traffic, perform the following steps to configure an access control policy to allow only the IP addresses of the dedicated WAF instances to access the origin server:

  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 Security > Web Application Firewall to go to the Dashboard page.
  4. In the navigation pane on the left, choose Instance Management > Dedicated Engine to go to the dedicated WAF instance page.
  5. In the IP Address column, obtain the IP address of each dedicated WAF instance under your account.
  6. Click in the upper left corner of the page and choose Networking > Elastic Load Balance.
  7. Locate the row containing the load balancer configured for your dedicated WAF instance and click the load balancer name in the Name column.
  8. In the Access Control row of the target listener, click Configure.
  9. In the displayed dialog box, select Whitelist for Access Control.

    1. Click Create IP Address Group and add the dedicated WAF instance IP addresses obtained in Step 5 to the group being created.
    2. Select the IP address group created in 9.a from the IP Address Group drop-down list.

  10. Click OK.

    Now, the access control policy allows all inbound traffic from the back-to-source IP addresses of your dedicated 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