Nginx node.js express download big files stop at 1.08GB
I have this node.js app proxied by Nginx (on production). A route is something like this:
exports.download = function(req, res){
var id = req.params.id;
if (id && id == 'latest')
{
res.download(config.items.release_directory+'/<1.6GB-file>.zip', function(err){
if (err) {
console.log(err);
} else {
// do something
}
});
}
else
{
res.redirect(301, '/');
}
};
So, clicking the right route/URL the browser starts to download the big file but then it stops always at 1.08GB (the file is about 1.6GB), truncating it.
I really cannot understand why. Any ideas?
EDIT: The config.items.release_directory is a static Express directory declared as:
app.use('/releases', express.static(path.join(__dirname, '..', 'releases')));
EDIT2: On development with grunt serving directly the app without Nginx it works fine.
SOLVED: read the comments below, problem is proxy_max_temp_file_size variable in Nginx
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)