Help Center> Web Application Firewall> FAQ> Service Interruption Check> How Do I Troubleshoot 404/502/504 Errors?

How Do I Troubleshoot 404/502/504 Errors?

If an error, such as 404 Not Found, 502 Bad Gateway, or 504 Gateway Timeout, occurs after a website is connected to WAF, use the following methods to locate the cause and remove the error:

404 Not Found Troubleshooting Process and Suggestions

Refer to Figure 1 to fix the 404 Not Found error occurred after your website is connected to WAF.

Figure 1 Troubleshooting for 404 Not Found error
  • If the page shown in Figure 2 is displayed, the possible causes and solutions are as follows:
    Figure 2 404 page

    Cause 1: A non-standard port is configured when you add the domain name to WAF, but the visitors use the domain name and standard port or use only the domain name to access the website. For example, a non-standard port is configured as shown in Figure 3. A visitor uses https://www.example.com or https://www.example.com:80 to access the website. As a result, 404 error page is displayed.
    Figure 3 Configuration of a non-standard port

    Solution: Add the non-standard port to the URL and access the origin server again, for example, https://www.example.com:8080.

    Cause 2: No non-standard port is configured when the domain name is added to WAF. The visitors use the domain name and a non-standard port or the non-standard port configured for origin server port to access the website. For example, access https://www.example.com:8080 when the protection service shown in Figure 4 is configured.
    Figure 4 Non-standard port not configured

    If no non-standard port is configured, WAF protects services on port 80/443 by default. To protect services on other ports, re-configure domain settings.

    Solution: Use only the domain name to access the website. For example, https://www.example.com.

  • If the response page is not similar the one shown in Figure 2, the possible causes and solutions are as follows:

    Cause: The website does not exist or has been deleted.

    Solution: Check the website.

502 Bad Gateway Troubleshooting Process and Solutions

Your website can be accessed normally after it is connected to WAF. However, after a period of time, the error code 502 is reported frequently. Refer to Figure 5 to fix the issue.

Figure 5 Troubleshooting process for 502 Bad Gateway error
Table 1 Troubleshooting 502 Bad Gateway error

Possible Cause

Solution

Cause 1: Your website is using another security protection software. Such software considers WAF back-to-source IP addresses as malicious and blocks the requests forwarded by WAF.

Configure an access control policy on the origin server to whitelist the WAF IP addresses.

Cause 2: Multiple backend servers are configured for the website. However, one backend server is inaccessible.

Repeat Step 1 to Step 6 to ensure that all origin servers can be accessed.

Cause 3: Your website server may have performance issues.

Contact your website administrator to rectify the fault.

If one of your backend website servers is unreachable, perform the following steps to ensure that the website server configuration is correct.

It takes about two minutes for server information modification to take effect.

  1. Log in to the management console.
  2. Go to the Website Settings page by following the steps shown in Figure 6.

    Figure 6 Accessing to the Website Settings page

  3. In the Protected Website column, click the domain name to go to the Basic Information page.
  4. In the Server Information area, click . On the displayed page, check whether the client protocol, server protocol, origin server address, and port number used by the origin server are correct.

    Figure 7 Server Configuration

  5. Check whether each origin server can be accessed properly.

    • Run the following command on the server:
      curl http://xx.xx.xx.xx:yy -kvv
      • xx.xx.xx.xx indicates the IP address of the origin server. yy indicates the port number of the origin server. xx.xx.xx.xx and yy must belong to the same origin server.
      • The host where the curl command can be run must meet the following requirements:
        • The network communication is normal.
        • The curl command has been installed. For hosts running a Windows operating system, curl must be manually installed on the hosts. For hosts running other operating systems, curl is installed automatically during operating system installation.
      Figure 8 Command output for checking origin server
      • If the command output indicates that the connection is normal, the website can be accessed.
      • If the command output returns connection refused, the origin server is unreachable and website cannot be accessed. Go to Step 6.
    • Enter http://origin server address: origin server port in the address box of the browser and press Enter.
      • If the website can be accessed, the website access is normal.
      • If the website cannot be accessed, the origin server is unreachable and the website cannot be accessed. Go to Step 6.

  6. Check whether the origin server runs properly.

    If not, restart it.

504 Gateway Timeout Troubleshooting Process and Solutions

After you connect your website to WAF, the possibility of 504 gateway timeout errors rises as your website traffic increases. In some other cases, there might be a possibility of 504 gateway timeout error if the visitors access your website through origin server IP addresses. Refer to Figure 9 to fix 504 gateway timeout errors.

Figure 9 Troubleshooting process for 504 Gateway Timeout errors
Table 2 Troubleshooting 504 Gateway Timeout errors

Possible Cause

Solution

Cause 1: Backend server performance issues (such as too many connections or high CPU usage)

  • Optimize the server configurations, including TCP network parameters and ulimit parameters.
  • If your website is connected to a cloud WAF instance, you are advised to add backend server groups or create new load balancers to support the increasing service workloads.
  • If you configure Client Protocol to HTTPS, to relieve burden on backend servers, configure HTTP for Server Protocol for WAF forwarding traffic to backend servers.

    For details, see Editing Server Information.

Cause 2

  • The WAF back-to-source IP addresses are not whitelisted or service port is not enabled in the security group.
  • WAF back-to-source IP addresses are blocked by the firewall on the origin server.

Configure an access control policy on the origin server to whitelist the WAF back-to-source IP addresses.

Cause 3: Connection timeout and read timeout

Contact technical support.

Cause 4: The bandwidth of the origin server exceeds the upper limit.

Increase the bandwidth of the origin server.

Create a load balancer. Use the EIP of the load balancer as the IP address of the origin server and connect the EIP to WAF.

It takes about two minutes for server information modification to take effect.

  1. Create a load balancer.
  2. Log in to the management console.
  3. Go to the Website Settings page by following the steps shown in Figure 10.

    Figure 10 Accessing to the Website Settings page

  4. In the Protected Website column, click the domain name to go to the Basic Information page.
  5. In the Server Information area, click . On the displayed page, click Add.

    Figure 11 Server Configuration

  6. Set the Server Address to the EIP bound to the load balancer.
  7. Click OK.