Environment
Ubuntu 20.04 server running NGINX 1.22 (compiled with http2), backend is Next.js API routes served by Node 18 behind a unix socket. Clients use modern browsers over HTTPS with HTTP/2 enabled. NGINX proxy_pass to http://unix:/var/run/next.sock:; body size limit default.
Symptoms
Large chunked POSTs to /api/upload are rejected by NGINX with 413 or behave as if empty body forwarded; Node logs show no body or early EOF. Direct requests to Next.js (bypassing NGINX) succeed. Small non-chunked POSTs work fine. Problem only occurs when client uses HTTP/2 to NGINX; HTTP/1.1 clients through same NGINX succeed.
Observations
NGINX error.log shows 'client intended to send too large body' intermittently and 'upstream sent no chunked data while requesting body'. client_max_body_size is at default 1m. fastcgi is not used. tcpdump shows the client sending DATA frames; NGINX sometimes responds with RST_STREAM for the stream. Upgrading NGINX to a build with http2 changes didn't help.
Already attempted
Increased client_max_body_size in site conf to 100m, restarted NGINX. Added proxy_request_buffering off; no change. Tested with curl using --http2 -v and saw early 413 when request exceeded ~1MB. Direct Node access tested OK. Tried proxying to backend over HTTP/1.1 (h2 disabled on listen) — then chunked uploads succeed.
Question
What NGINX or HTTP/2 proxy settings are causing chunked Transfer-Encoding bodies to be dropped or rejected when using HTTP/2, and how to make NGINX reliably forward chunked uploads to the Next.js backend without disabling HTTP/2?
Verified community troubleshooting
Most often this is the proxy buffering/size path: add a larger client_max_body_size and disable buffering for the upload route. In your location block set client_max_body_size 200m; proxy_request_buffering off; proxy_http_version 1.1; proxy_set_header Connection "";. Restart nginx and retry with curl --http2 -v to confirm Node receives the POST body. If uploads still fail, enable nginx debug for http2/proxy to capture DATA frame handling, and consider testing with an upstream over HTTP/1.1 to isolate an http2-to-upstream translation bug. Roll back changes if other endpoints regress.
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Web Development43% match
NGINX returns 413 for Transfer-Encoding: chunked uploads only when proxying to Node.js over HTTP/2 TLS offload
Solved1 answer - Web Development41% match
Next.js serverless API returns 502 for large Transfer-Encoding: chunked uploads only when behind NGINX reverse proxy
Open0 answers - Web Development38% match
NGINX reverse proxy returns 413 for Transfer-Encoding: chunked uploads to Next.js API while direct Node accepts them
Open0 answers - Web Development33% match
Next.js serverless API on Vercel returns intermittent 504s for long upstream requests when HTTP keep-alive sockets are exhausted
Open0 answers - Networking31% match
Chunked Transfer-Encoding uploads fail with 413 only through TLS-terminating NGINX proxy
Open0 answers