NGINX reverse proxy returns 413 for Transfer-Encoding: chunked uploads to Next.js API while direct Node accepts them
Environment
Next.js 13 app using custom server (Node.js 18), fronted by NGINX 1.20 as reverse proxy with default proxy_buffering settings, client_max_body_size set to 50M, hosted on Ubuntu 22.04.
Symptoms
Large multipart uploads sent with Transfer-Encoding: chunked receive HTTP 413 Request Entity Too Large from NGINX. The same upload sent directly to the Node/Next server bypassing NGINX succeeds. Short or non-chunked uploads through NGINX work fine.
Observations
NGINX access/error logs show 413 and 'client intended to send too large body'. client_max_body_size is already > file size. Turning off buffering at the upstream level was attempted with no immediate effect until NGINX restart. When proxy_request_buffering is off, uploads stream to upstream and the issue disappears.
Already attempted
Increased client_max_body_size in nginx.conf (no effect), set proxy_buffering off in location block (fixed after restart), tested with curl -H 'Transfer-Encoding: chunked' confirming behavior, checked upstream Next.js server logs (no 413).
Question
Why does NGINX return 413 for chunked uploads even when client_max_body_size is large, and what is the safe, production-ready way to accept chunked uploads through NGINX to Next.js endpoints?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Web Development53% match
Next.js serverless API returns 502 for large Transfer-Encoding: chunked uploads only when behind NGINX reverse proxy
Open0 answers - Web Development45% match
NGINX HTTP/2 proxy drops chunked Transfer-Encoding uploads to Next.js API routes — request body never reaches Node
Solved1 answer - Web Development44% match
NGINX returns 413 for Transfer-Encoding: chunked uploads only when proxying to Node.js over HTTP/2 TLS offload
Solved1 answer - Web Development35% match
NGINX returns 413 Request Entity Too Large for chunked uploads only when client uses Transfer-Encoding: chunked
Open1 answer - Networking33% match
Chunked Transfer-Encoding uploads fail with 413 only through TLS-terminating NGINX proxy
Open0 answers