nginx x-accel-redirect request method named location

hemendra26 nginx-forum at forum.nginx.org
Wed Dec 14 21:26:18 UTC 2016


hemendra26 Wrote:
-------------------------------------------------------
> I was using nginx  x-accel-redirect as an authentication frontend for
> an external db resource.
> 
> In my python code I would do the following:
> 
> /getresource/
> 
> def view(self, req, resp):
>      name = get_dbname(req.user.id)
>      resp.set_header('X-Accel-Redirect', '/resource/%s/' %name )
> 
> This would forward the HTTP method as well until nginx 1.10 
> Since nginx 1.10 all x-accel-redirects are forwarded as GET methods.
> 
> From this thread:
> https://forum.nginx.org/read.php?2,271372,271380#msg-271380
> 
> I understand that the correct way to forward the HTTP method is to use
> named location. 
> I am unable to find documentation on how this should be done.
> I tried the following:
> 
> def view(self, req, resp):
>         name = get_dbname(req.user.id)
>         resp.set_header('X-Accel-Redirect', '@resource'  )
> 
> but this redirects to @resource /
> I would like to redirect to @resource /name

Edit:

Posting configs for nginx, hope someone can help. 

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;
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271448,271528#msg-271528



More information about the nginx mailing list