To upload pictures to nodejs(on a dev machine) I use the following approach:

var http=require('http'),

function(req, res) {
    var busboy=new Busboy({headers: req.headers});
    busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
      var saveTo=path.join(os.tmpDir(), path.basename(fieldname));
    busboy.on('finish', function() {
      res.writeHead(200, {'Connection':'close'});
      res.end("That's all folks!");
    return req.pipe(busboy);

The production server costs nginx and I need to understand how to configure it so that, on the nodejs side, performance is not lost and the ability to stream files is preserved.

nginx proxies requests from NodeJS as follows:

upstream node_upstream {
    keepalive 64;

server {
    listen 80;

        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Connection"";
        client_max_body_size 10m;
        client_body_buffer_size 128k;
        proxy_http_version 1.1;
        proxy_pass http://node_upstream;
        proxy_intercept_errors on;

Tell me how to properly configure nginx to stream files using nodejs?

1 Answers 1

Look towards using a specialized module for Nginx and Node.js interaction - Phusion Passenger.Everything should be in order with similar optimization without any additional settings, according to the idea.Architecture and settings documentation, if that - very detailed.