Nginx node.js express download big files stop at 1.08GB Nginx node.js express download big files stop at 1.08GB express express

Nginx node.js express download big files stop at 1.08GB


Here the matter is nginx configuration, not nodejs code.

nginx write temp files in disk before sending them to the client, it's often a good idea to disable this cache if the site is going to serve big static files, with something like:

location / {    proxy_max_temp_file_size 0;}

(no limit)


In case of uploading a file while proxying with Nginx, you can set "max body size" inside of you server{} block in Nginx config:

client_max_body_size 0; # disable any limits to avoid HTTP 413

If you are getting HTTP 413, check your Nginx config and either set it to zero or crank it up, accordingly.

Otherwise, I'd try to increase some timeouts, such as these:

send_timeout 600s; # default is 60s; context: http, server, locationproxy_read_timeout 600s; # default is 60s; context: http, server, locationproxy_send_timeout 600s; # default is 60s; context: http, server, location

For more proxy options, checkout Nginx Proxy module documentation (link).


I strongly discourage setting proxy_max_temp_file_size 0 as this will have the effect of removing any proxy buffer for all your endpoints.

This means that your application server won't be able to flush response data into an NGINX buffer (from which the downstream client can read whenever it gets sufficient connectivity) and be released/unblocked. Instead your application server will be waiting for the client (no NGINX proxy in the middle) to download the data.

Alternatively, you could instruct your NGINX proxy to selectively not buffer response data when streaming your zipfile data to avoid any potential issues with NGINX's buffer tempfile getting full and interrupting streaming downloads (which was my experience).

You can achieve this by doing something like the following in your Node.js endpoint:

res.set('X-Accel-Buffering', 'no');

This way the data will be streamed directly from Express to clients but only for the endpoints for which you don't want response data buffered (most likely your streaming endpoint(s)).