小编aci*_*fix的帖子

Nginx x-accel 重定向命名位置 uri

我使用 nginx x-accel-redirect 作为外部资源的身份验证前端。

在我的 python 代码中,我将执行以下操作:

/获取资源/

def view(self, req, resp): 
    name = get_name(req.user.id) # authenticates request.
    resp.set_header('X-Accel-Redirect', '/resource/%s/' %name ) 
Run Code Online (Sandbox Code Playgroud)

这也将转发 HTTP 方法,直到 nginx 1.10。从 nginx 1.10 开始,所有 x-accel-redirects 都作为 GET 方法转发。

从这个线程:https : //forum.nginx.org/read.php?2,271372,271380#msg-271380

我知道转发 HTTP 方法的正确方法是使用命名位置。我无法找到有关如何完成此操作的文档。我尝试了以下方法:

def view(self, req, resp): 
    name = get_name(req.user.id) 
    resp.set_header('X-Accel-Redirect', '@resource' ) 
Run Code Online (Sandbox Code Playgroud)

但这会重定向到“@resource /”。

我想重定向到“@resource /name”。

我也在 nginx 论坛上问过这个问题:https ://forum.nginx.org/read.php ?2,271448

但还没有回应。

编辑:

发布 nginx 配置

location /getresource {
   proxy_pass http://127.0.0.1:8000;
}

location /resource {
    internal;
    proxy_pass http://127.0.0.1:8888;
}

location …
Run Code Online (Sandbox Code Playgroud)

python nginx falcon x-accel-redirect

2
推荐指数
1
解决办法
1308
查看次数

标签 统计

falcon ×1

nginx ×1

python ×1

x-accel-redirect ×1