Nginx rejects request bodies larger than 1 MB by default, returning 413 Request Entity Too Large before the request ever reaches your app. Raise the limit to whatever you actually want to allow.
Site-wide (in http { } or a server { }):
client_max_body_size 100m;
Or just on the upload endpoint, keeping the rest tight:
location /upload {
client_max_body_size 500m;
proxy_pass http://127.0.0.1:3000;
# Big uploads can take a while — don't time out mid-transfer.
proxy_request_buffering off; # stream to the backend instead of buffering whole body to disk
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
Details:
client_max_body_size 0;disables the check entirely (unlimited) — usually a bad idea; pick a real ceiling.- The directive is inherited, so set it at
httpfor a global default and override perlocationfor upload paths. 413still appearing after raising it? Check you edited the server block that actually handles the request, and reload (not justnginx -t). If a separate reverse proxy or CDN sits in front, raise its limit too.- For streaming large files to a backend,
proxy_request_buffering off;avoids buffering the entire body to a temp file first. For PHP-FPM, also raiseupload_max_filesizeandpost_max_sizeinphp.ini.
sudo nginx -t && sudo nginx -s reload