How to configure protected access to files on remote nginx with X-Accel-Redirect

I have 2 servers. First ( is a django/apache server, second ( is a file server (nginx). Some files are protected and should only be allowed to be downloaded by registred users. To that end I have setup a nginx server with a

server {
        listen 80 default_server;
        server_name *;
        access_log /home/domain/logs/access.log;
        location /files/ {
             root /home/domain;

and from Django I send a request via X-Accel-Redirect header, but it doesn't work. I think because the request comes from a remote server.

How can I accomplish this task?


"and from django I send a request via X-Accel-Redirect header" -- it's incorrect, the "X-Accel" header must be a part of response header from the upstream server.

As said, there must be a proxy_pass or fastcgi_pass directive to send the response header to nginx.

location /protected_files { 

Need Your Help

Handle argc equal to 0

c++ c argc

I recently saw something curious. In the HHVM source code, the very first 3 lines of the main() function read as follows: