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

Python Nginx x-accel重定向命名位置uri,python,nginx,falcon,x-accel-redirect,Python,Nginx,Falcon,X Accel Redirect,我使用nginx x-accel-redirect作为外部资源的身份验证前端 在python代码中,我将执行以下操作: def view(self, req, resp): name = get_name(req.user.id) resp.set_header('X-Accel-Redirect', '@resource' ) /获取资源/ def view(self, req, resp): name = get_name(req.user.id) # au

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

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

def view(self, req, resp): 
    name = get_name(req.user.id) 
    resp.set_header('X-Accel-Redirect', '@resource' ) 
/获取资源/

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。 由于nginx 1.10,所有x-accel重定向都作为GET方法转发

从该线程:

我知道转发HTTP方法的正确方法是使用命名位置。 我找不到关于如何做到这一点的文档。 我尝试了以下方法:

def view(self, req, resp): 
    name = get_name(req.user.id) 
    resp.set_header('X-Accel-Redirect', '@resource' ) 
但这会重定向到“@resource/”

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

我也在nginx论坛上问过这个问题:

但还没有回应

编辑:

为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论坛的答案贴出来

这就是你要做的。因为您不能使用X-Accel-Redirect设置不同的 位置,您应该在nginx config do中使用位置和设置其他标头 大概是这样的:

location @resources {
    set $stored_real_location $upstream_http_x_real_location;
    proxy_pass http://resources-backend$stored_real_location;
}
在上面的示例中,Python代码应设置以下标题:

X-Accel-Redirect: @resources
X-Real-Location: /some/other/path...

既然没有人在这里回答,我想把nginx论坛的答案贴出来

这就是你要做的。因为您不能使用X-Accel-Redirect设置不同的 位置,您应该在nginx config do中使用位置和设置其他标头 大概是这样的:

location @resources {
    set $stored_real_location $upstream_http_x_real_location;
    proxy_pass http://resources-backend$stored_real_location;
}
在上面的示例中,Python代码应设置以下标题:

X-Accel-Redirect: @resources
X-Real-Location: /some/other/path...

能否在/getresource/和/resource/locations的部分中发布nginx配置?能否在/getresource/和/resource/locations的部分中发布nginx配置?