Symptom
After you configure Anti-DDoS Pro or Anti-DDoS Premium for your service, uploading a large file over HTTP or HTTPS fails with the following error:
413 Request Entity Too Large
The requested resource does not allow request data with the requested method
or the amount of data provided in the request exceeds the capacity limit.The HTTP 413 Request Entity Too Large status code indicates that the request body exceeds the size limit allowed by the server or an intermediary proxy.
Cause
The cause depends on the size of the file you are uploading:
File is larger than 2 GB: Anti-DDoS Pro or Anti-DDoS Premium is built on the Tengine architecture and functions as a reverse proxy service. There is a limit on the size of uploaded files of 2 GB.
File is smaller than 2 GB: The origin server (the backend service behind Anti-DDoS Proxy) is limiting the upload size. This is typically caused by a web server configuration such as the Nginx
client_max_body_sizedirective.
Upload size limits by product
| Product | Maximum upload size |
|---|---|
| Anti-DDoS Pro or Anti-DDoS Premium | 2 GB |
| Web Application Firewall (WAF) | 2 GB |
| Server Load Balancer (SLB) | 50 GB |
Solution
Determine the size of the file you are trying to upload, then follow the appropriate solution.
File is larger than 2 GB
If your file exceeds the 2 GB upload size limit, use one of the following workarounds:
Compress the file before uploading Compress the file to less than 2 GB, and then upload the compressed file.
Upload the file to Object Storage Service (OSS) instead Upload the file directly to OSS, bypassing Anti-DDoS Proxy entirely. For more information, see Upload objects.
The maximum size of a single uploaded object varies by OSS API operation. The PutObject and PostObject operations support a maximum of 5 GB per object. The multipart upload API has an effectively unlimited maximum size, so there is no practical constraint for large files.
Upload through an address that is not protected by Anti-DDoS Proxy Bypass Anti-DDoS Pro or Anti-DDoS Premium by uploading the file through an origin server address that is not routed through the Anti-DDoS Proxy service.
File is smaller than 2 GB
If your file is smaller than 2 GB but the upload still fails with a 413 error, the origin server is rejecting the request. Check and adjust the upload size limit on your backend web server.
The following example uses Nginx:
Open the
nginx.confconfiguration file and add or modify the following directive:client_max_body_size [$Num]Set
[$Num]to a value greater than the size of the file you need to upload. This value defines the maximum allowed request body size for Nginx.Verify that the configuration file syntax is correct:
nginx -tReload Nginx to apply the change:
nginx -s reload
Applies to
Anti-DDoS (Anti-DDoS Pro and Anti-DDoS Premium)