title: EPIPE Error with ExpressJS, nginx proxy server
body: <p>I am running multiple ExpressJS Node apps through an Nginx proxy server, and am getting an EPIPE Error thrown whenever my users try to download a file. This does not happen on my local setup (which is identical to the server's except for the proxy server), so I figure it has something to do with my Nginx configuration.</p>
  
  <p>Here are my Nginx configs:</p>
  
  <h3>/etc/nginx/nginx.conf</h3>
  
  <pre><code>user                    www www;
  worker_processes        1;
  error_log               /home/alex/logs/error.log;
  pid                     /var/run/nginx.pid;
  worker_rlimit_nofile    8192;
  
  events {
      worker_connections  4096;  ## Default: 1024
  }
  
  http {
      include         mime.types;
      index           index.html index.htm index.php;
      default_type    application/octet-stream;
      log_format      main '$remote_addr - $remote_user [$time_local]  $status '
                           '"$request" $body_bytes_sent "$http_referer" '
                           '"$http_user_agent" "$http_x_forwarded_for"';
      access_log      /home/alex/logs/access.log  main;
      sendfile        on;
      tcp_nopush      on;
      gzip            on;
  
      server_names_hash_bucket_size 128; # this seems to be required for some vhosts
  
      include /etc/nginx/conf.d/*.conf;
  }
  </code></pre>
  
  <h3>/etc/nginx/conf.d/default.conf</h3>
  
  <pre><code>server {
      listen       80;
      server_name  example.com;
  
      # log access and stuff
      access_log  /home/alex/logs/example-site.log  main;
  
      # Load configuration files for the default server block.
      include /etc/nginx/default.d/*.conf;
  
      # Proxy to the NodeJS server
      location / {
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_pass http://127.0.0.1:8999;
      }
  
      # redirect server error pages to their HTML
      include /etc/nginx/errpages.conf;
  }
  </code></pre>
  
  <p>The ExpressJS server is sending the download using the following code:</p>
  
  <pre><code>app.get('/citrite/p/:patch', function(req, res)
  {
      if(set.citFiles.indexOf(req.params.patch) == -1)
      {
          res.send(mbuild.get404());
      }
      else
      {
          track.incrViewcount(req.params.patch, 'citrite');
          res.download(set.citDir + '/' + req.params.patch, files.doneSaving);
      }
  });
  </code></pre>
  
  <p>That code and everything else works fine on my local git repo, but when I push from there and pull on the server-side, the site kicks and screams - it times out on the user's end and gives me an EPIPE error in the console. I am running Node.js version 4.2.1 and ExpressJS version 4.13.3.</p>