title: Nginx X-Accel-Redirect not working with node.js
body: <p>I'm trying to set up authorized file access on nginx backed by node.js. For some reason all the examples don't work for me. I'm trying to server files from <code>/data/private/files</code></p>
  
  <p>My nginx configuration:</p>
  
  <pre><code>...
  server {
      listen 4000;
      server_name localhost;
  
      location / {
          proxy_pass http://127.0.0.1:3000/;
      }
  
      location /files {
          root /data/private;
          internal;
  }  
  </code></pre>
  
  <p>My node server.js:</p>
  
  <pre><code>var http = require('http');
  http.createServer(function (req, res) {
    console.log(req.url);
    res.end('works');
  }).listen(3000);
  </code></pre>
  
  <p>When I request <code>http://localhost:4000/xyz</code> then the request is correctly being passed on to node. When I request <code>http://localhost:4000/files/test.jpg</code> I just get a 404 and nothing gets passed to node. What am I doing wrong? When I commend out <code>internal</code> then test.jpg gets served correctly by nginx directly, so I assume the paths are correct?</p>
  
  <p>I'm pretty sure I had this working at some point before but on a different server somewhere maybe with a different node and nginx version. Tried it with nginx 1.6.0 and 1.2.6, node v0.10.21. I've also added all the proxy_set_header and proxy_pass options that you find in all the examples, nothing works. I'm running this in a Vagrant based Ubuntu VM right now, but doesn't work on Mac either.</p>
  
  <p>I know that I have to set the header through <code>res.setHeader("X-Accel-Redirect", req.url);</code>, but that's not the issue here as I don't even get to that phase where I could set the required header in node.</p>