【问题标题】:How to configure protected access to files on remote nginx with X-Accel-Redirect如何使用 X-Accel-Redirect 配置对远程 nginx 上文件的受保护访问
【发布时间】:2012-09-01 09:48:45
【问题描述】:

我有 2 台服务器。第一个(domain.com)是一个 django/apache 服务器,第二个(f1.domain.com)是一个文件服务器(nginx)。某些文件受到保护,只能由注册用户下载。为此,我设置了一个 nginx 服务器,其中包含一个

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

从 Django 我通过 X-Accel-Redirect 标头发送请求,但它不起作用。我想是因为请求来自远程服务器。

我怎样才能完成这项任务?

【问题讨论】:

  • 我对你的问题有点困惑。请详细说明。

标签: django apache nginx


【解决方案1】:

“从 django 我通过 X-Accel-Redirect 标头发送请求”——这是不正确的,“X-Accel”标头必须是来自上游服务器的响应标头的一部分。

正如http://wiki.nginx.org/X-accel所说,必须有proxy_pass或fastcgi_pass指令才能将响应头发送给nginx。

location /protected_files { 
    internal;
    proxy_pass http://127.0.0.2; 
}

【讨论】:

  • 也许你可以更清楚一点,Apache/Django 服务器和 nginx 文件服务器前面应该有一个 nginx 反向代理(或者让反向代理也充当文件服务器) .有点像this snippet
猜你喜欢
  • 2015-04-29
  • 1970-01-01
  • 2018-02-02
  • 1970-01-01
  • 1970-01-01
  • 2011-03-17
  • 2021-12-24
  • 2013-04-17
相关资源
最近更新 更多