When a request to a CDN-accelerated resource returns a 403 error, or your domain name shows traffic anomalies or suspected malicious traffic theft, use the symptom categories in this topic to identify the cause and resolve it. This topic covers troubleshooting issues only. For configuration and consultation questions, see FAQ about access control.
Symptom quick reference
Use curl -v or the browser developer tools to check the X-Tengine-Error field in the response headers, and locate the cause against the following table:
Note: If the X-Tengine-Error field exists in the response headers but its value is not in the preceding table, or remote authentication is enabled for the domain name, see 403 errors caused by remote authentication.
How do I determine whether the 403 error is returned by CDN or by the origin server?
When a request to an accelerated resource returns a 403 error, first determine where the 403 error comes from, and then troubleshoot based on the corresponding symptom family:
-
If the response headers do not contain the X-Tengine-Error field, modify the local hosts file to map the accelerated domain name to the IP address of the origin server, and access the origin server directly to verify. If the origin server also returns a 403 error, the access control policy of the origin server itself blocked the request. See 403 errors returned by the origin server. For general troubleshooting methods on the origin server side, see Troubleshooting guide about origin fetch.
403 errors caused by URL authentication
After URL authentication is enabled, CDN returns a 403 error if a request does not carry the signing parameter or the signing parameter is invalid. Use the X-Tengine-Error: denied by req auth message in the response headers to determine the specific cause.
Note: URL authentication only controls access permissions, and the authentication result does not affect the caching behavior of CDN. After authentication passes, the CDN node removes the signing parameter (such as auth_key) from the URL and uses the original URL as the cache key, so different signed URLs generated by different users for the same resource hit the same cached content. Expired authentication only causes subsequent new requests to be blocked with a 403 error and does not invalidate resources that are already cached.
Error denied by req auth: no url arg auth_key (no signing parameter is carried)
-
Cause: URL authentication is enabled on CDN, but the URL that is actually accessed does not carry the signing parameter.
-
Solution: If you need the authentication feature, follow Configure URL signing to generate and carry the correct signing parameter for requests. If you do not need the authentication feature, log on to the CDN console and disable URL authentication for the domain name.
Error denied by req auth: expired timestamp (the signing has expired)
-
Cause: The URL carries the signing parameter, but the timestamp in the signing parameter has expired. The validity period of a signed URL is determined by the validity duration that you configured. The signing becomes invalid after the validity duration elapses.
-
Solution: See Configure URL signing to regenerate the signed URL. If your business pages take a long time to load, you can appropriately extend the signing validity duration.
Error denied by req auth: invalid md5hash (authentication calculation error)
-
Cause: The MD5 value of the signing parameter is calculated incorrectly. This is usually caused by a mismatch between the signature algorithm of your signing code and the requirements of the CDN authentication method.
-
Solution: We recommend that you first use the URL generator in the CDN console to generate a signed URL, compare it field by field with the URL generated by your own signing code, and locate the signature difference. For the signature algorithm of each authentication method, see Type A signing. For signing code examples, see URL signing examples.
403 errors caused by the Referer blacklist/whitelist
After you configure a Referer blacklist/whitelist, CDN returns a 403 error if the Referer of a request does not match the rules. The error message in the response headers is X-Tengine-Error: denied by Referer ACL. You can run the curl -e "<Referer value>" <accelerated resource URL> command to simulate a request that carries a specified Referer and verify the behavior.
A request that carries a Referer is blocked (denied by Referer ACL)
-
Cause: The Referer carried by the request is not in the whitelist, or matches the blacklist. This commonly happens when the whitelist omits the domain name of the site that actually references the resources.
-
Diagnosis: In the CDN console, check the Referer blacklist/whitelist configuration of the accelerated domain name and determine whether the Referer of the blocked request matches the rules. You can also download the CDN logs to find the Referer header of the corresponding access record.
-
Solution: Add the blocked Referer to the whitelist (or remove it from the blacklist). For the configuration method, see Configure a Referer blacklist or whitelist.
A request with an empty Referer is blocked (accessing the URL directly returns a 403 error)
-
Cause: Requests in the following scenarios do not carry a Referer (an empty Referer): accessing a resource URL directly from the browser address bar; constructing requests in apps or client programs without setting the Referer header; an HTTPS page referencing HTTP resources, in which case the browser does not send the Referer based on the default Referrer-Policy; the page explicitly setting Referrer-Policy: no-referrer; and using command-line tools such as curl or wget, which do not carry a Referer by default. If Allow direct access to resource URLs from the browser address bar is not selected in the Referer blacklist/whitelist configuration, requests with an empty Referer are blocked.
-
Solution: If your business needs to allow access with an empty Referer, select Allow direct access to resource URLs from the browser address bar in the Referer blacklist/whitelist configuration. If you intentionally block empty Referer requests to prevent traffic theft, do not allow them, and see Traffic anomalies and malicious traffic theft to configure more fine-grained mitigation policies. For the configuration method, see Configure a Referer blacklist or whitelist.
403 errors caused by other CDN access control features
403 errors caused by the IP blacklist/whitelist
After you configure an IP blacklist/whitelist, the CDN node rejects a request and returns a 403 error if the client IP address matches the blacklist or is not in the whitelist. The response header X-Tengine-Error: denied by IP ACL = blacklist indicates that the IP address matches the IP blacklist, and X-Tengine-Error: denied by IP ACL = not in whitelist indicates that the IP address is not in the IP whitelist.
-
Diagnosis: First confirm the real public IP address of the client (you can query it by running curl ifconfig.me or curl myip.ipip.net). If requests pass through a proxy or load balancer, the client IP address obtained by CDN may be the proxy IP address rather than the end user IP address, and you need to confirm the client IP address actually identified by the CDN node. In the CDN console, check the IP blacklist/whitelist configuration of the domain name and confirm whether the IP address matches the rules.
-
Solution: First confirm whether the block is intended. If you need to allow the IP address, on the Domain Names page in the CDN console, click Manage for the target domain name. In the left-side navigation pane, click Access Control, and adjust the rules in the IP Blacklist/Whitelist section. For the configuration method, see Configure IP blacklist or whitelist. If an IP address in the IP blacklist can still access the resources, see FAQ about access control.
403 errors caused by the UA blacklist/whitelist
After you configure a UA blacklist/whitelist, the CDN node rejects a request and returns a 403 error if the User-Agent in the request header matches the UA blacklist or is not in the UA whitelist. The response header X-Tengine-Error: black ua indicates that the User-Agent matches the UA blacklist, and X-Tengine-Error: not in white ua indicates that the User-Agent is not in the UA whitelist.
-
Diagnosis: Run curl -v <accelerated resource URL> to check the User-Agent value that the request actually sends, or check the request headers in the browser developer tools. In the CDN console, check the UA blacklist/whitelist rules of the domain name and confirm whether the User-Agent matches. Note that the UA blacklist/whitelist supports wildcard matching, so check whether the User-Agent is unexpectedly matched by a wildcard rule.
-
Solution: First confirm whether the block is intended. If you need to allow the request, on the Domain Names page in the CDN console, click Manage for the target domain name. In the left-side navigation pane, click Access Control, and adjust the rules on the UA Blacklist/Whitelist tab. For the configuration method, see Configure a User-Agent blacklist or whitelist.
403 errors caused by remote authentication
After remote authentication is enabled, the CDN node forwards requests to the authentication server that you specified for verification. Requests are blocked and a 403 error is returned in the following two cases:
-
The authentication server returns the Authentication Failure Status Code defined in the configuration (for example, 403). CDN determines that authentication failed and rejects the request.
-
Authentication times out (the interaction between the CDN node and the authentication server does not complete within the configured timeout period), and Action After Authentication Timeout is set to Reject.
-
Diagnosis: If the 403 error does not belong to any of URL authentication, Referer, IP ACL, or UA ACL described above (the X-Tengine-Error value in the response headers does not match any of them), and remote authentication is enabled for the domain name, you should troubleshoot remote authentication first. In the CDN console, check Authentication Failure Status Code, Authentication Timeout Settings, and Action After Authentication Timeout in the remote authentication configuration of the domain name, and then check the access logs of the authentication server to confirm the status code that the authentication server actually returned and whether timeouts occurred.
-
Solution: If the block is not intended, adjust the verification logic of the authentication server or the authentication failure status code configuration. If authentication frequently times out, troubleshoot the performance of the authentication server (the timeout period can be set to a maximum of 3,000 milliseconds), or set Action After Authentication Timeout to Allow based on your business risk assessment. For the configuration method, see Configure remote authentication.
403 errors returned by the origin server
If the response headers do not contain the X-Tengine-Error field and X-Cache is MISS, the CDN cache missed and the origin server returned a 403 error after the origin fetch. In this case, you need to troubleshoot the access control policies of the origin server itself.
403 errors when the origin server is OSS (AccessDenied and other errors)
The 403 error is returned by the OSS origin server. There are three common error messages:
-
The error You have no right to access this object because of bucket acl: The bucket has private read permissions, and the origin fetch request of CDN does not pass OSS authentication. We recommend that you enable origin fetch authorization for private OSS buckets in the CDN console. For the configuration method, see Configure origin fetch from a private OSS bucket.
-
The error You are denied by bucket referer policy: A Referer blacklist/whitelist is configured for the bucket, and the Referer of the origin fetch request of CDN does not match the rules of the bucket. Check the Referer blacklist/whitelist settings of the bucket in the OSS console and allow access from the origin fetch requests of CDN (for example, allow an empty Referer, or add the Referer carried by the origin fetch requests of CDN to the whitelist).
-
The error You are forbidden to list buckets: Private bucket origin fetch of CDN and static website hosting of OSS are enabled at the same time, and the two features conflict with each other. Disable one of them: disable origin fetch authorization for private CDN buckets, or disable the static website hosting feature of OSS. For the conflict description, see What can I do if errors arise after I enable access to private OSS buckets and static website hosting?.
403 errors caused by the origin host or other origin server policies
-
Cause: When CDN performs an origin fetch, the origin host determines which site on the origin server IP address the origin fetch request accesses. If the origin host is configured incorrectly, the request may be matched to a site that does not provide services or that has access restrictions on the origin server, and the origin server returns a 403 error. In addition, the firewall rules, WAF policies, or application-layer access control of the origin server itself may also block the origin fetch requests of CDN.
-
Diagnosis: Map the accelerated domain name to the IP address of the origin server by binding the hosts file, access the origin server directly, and verify whether it also returns a 403 error. Check the origin host configuration in the CDN console and confirm that it points to the site that actually provides services on the origin server.
-
Solution: Correct the origin host configuration to ensure that the origin host points to the site that actually provides services on the origin server. If the firewall or WAF of the origin server blocks the origin fetch requests of CDN, add the origin fetch IP address ranges of CDN to the whitelist of the origin server. For general troubleshooting methods on the origin server side, see Troubleshooting guide about origin fetch.
Traffic anomalies and malicious traffic theft
When a domain name is attacked or its traffic is maliciously stolen, sudden high bandwidth or heavy traffic is generated, which mainly brings two risks:
-
The domain name is moved to a sandbox: Alibaba Cloud CDN is a public acceleration service and does not provide anti-attack capabilities by default. When a domain name is attacked, CDN has the right to move the domain name to a sandbox based on the business situation and the severity of the attack impact, to avoid affecting the acceleration services of other users. If the attacks are severe, other domain names under the same account may also be moved to a sandbox, and onboarding of new domain names under the account is restricted. After a domain name enters the sandbox, CDN no longer guarantees the service quality. For more information about the sandbox, see Sandbox overview.
-
Malicious access leads to unexpectedly high bills: Attacks and traffic theft actually consume CDN bandwidth resources. The resulting bandwidth costs are borne by you, which can easily lead to unexpectedly high bills and may even cause the account to be suspended due to overdue payments. For more information about service suspension protection and cost control, see High bill risk warning.
How do I confirm whether the domain name is suffering from traffic theft or attacks?
Preliminarily confirm it in the following ways:
-
Log on to the CDN console and check the bandwidth and traffic trends of the domain name in Monitoring Reports. Check whether abnormal peaks occur outside business hours.
-
Download the CDN access logs of the domain name, analyze the IP address distribution, Referer distribution, and User-Agent distribution of access sources, and identify abnormally high-frequency IP address ranges, abnormal Referer sources, or crawler-like User-Agents.
-
Check in CloudMonitor whether bandwidth or traffic alerts have been triggered.
How do I protect against and handle it?
We recommend that you take protective measures in advance: configure alarm rules for peak bandwidth and downstream traffic through the alarm settings feature so that you are notified promptly when the thresholds are reached; and configure access control policies such as an IP blacklist, a Referer blacklist, a UA blacklist, or URL authentication based on attack characteristics to block the attacks. For blocking solutions against traffic theft scenarios, see Prevent traffic abuse.
If the domain name has been moved to a sandbox, wait until the attack traffic subsides and then submit a ticket to request removal from the sandbox. To avoid triggering it again, we recommend that you configure the access control policies before the removal.