我使用nginx x-accel-redirect作为外部资源的身份验证前端。在
在python代码中,我将执行以下操作:
/getresource/
def view(self, req, resp):
name = get_name(req.user.id) # authenticates request.
resp.set_header('X-Accel-Redirect', '/resource/%s/' %name )
这也会将HTTP方法转发到nginx1.10。 由于nginx1.10,所有x-accel-redirect都作为GET方法转发。在
从这个线程: https://forum.nginx.org/read.php?2,271372,271380#msg-271380
我知道转发HTTP方法的正确方法是使用命名位置。 我找不到关于该如何做的文件。 我尝试了以下方法:
^{pr2}$但这会重定向到“@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 @resource {
internal;
proxy_pass http://127.0.0.1:8888;
}
因为没有人在这里回答,所以我想在nginx论坛上发表答案。在
https://forum.nginx.org/read.php?2,271448,271549#msg-271549
嗨
给你做什么。因为您不能使用X-Accel-Redirect来设置不同的 location,你应该在nginx config do中用location和设置其他头 像这样:
在上面的示例中,Python代码应该设置以下头:
^{pr2}$相关问题 更多 >
编程相关推荐