Fix Tengine 413 Request Entity Too Large error

2026-09-29

AdSense Slot

You added a file upload feature, tested with a small file and it worked, then a user tried to upload something bigger and got 413 Request Entity Too Large. This is one of the most common Tengine errors behind upload forms, and the fix is a single directive — but where you put it matters.

Why it happens

Tengine limits the maximum request body size with client_max_body_size, and the default is only 1MB. Any upload bigger than that is rejected before it reaches your Spring Boot or PHP backend.

The fix

Set a sensible limit in the http, server, or location block. For an upload endpoint, 20MB is a common value:

http {
    client_max_body_size 20m;
}

Prefer the server block if only one site needs it, or the location block if only the upload path does:

location /upload {
    client_max_body_size 50m;
    proxy_pass http://springboot-backend;
}

What I learned the hard way

Verify

curl -X POST --data-binary @bigfile.bin https://yourdomain.com/upload -o /dev/null -w "%{http_code}\n"

If you still get 413 with the size set correctly, check whether another proxy layer (a CDN or an upstream like Java’s Tomcat with its own limit) is the one rejecting it.

Summary

client_max_body_size defaults to 1MB; raise it at the right block level and reload. While you are fixing upload paths, my 502 troubleshooting guide covers the other error that shows up right after a new feature deploy.

AdSense Slot