<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 10, 2016 at 9:08 PM, hemendra26 <span dir="ltr"><<a href="mailto:nginx-forum@forum.nginx.org" target="_blank">nginx-forum@forum.nginx.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I was using nginx  x-accel-redirect as an authentication frontend for an<br>
external db resource.<br>
<br>
In my python code I would do the following:<br>
<br>
/getresource/<br>
<br>
def view(self, req, resp):<br>
     name = get_dbname(<a href="http://req.user.id" rel="noreferrer" target="_blank">req.user.id</a>)<br>
     resp.set_header('X-Accel-<wbr>Redirect', '/resource/%s/' %name )<br>
<br>
This would forward the HTTP method as well until nginx 1.10<br>
Since nginx 1.10 all x-accel-redirects are forwarded as GET methods.<br>
<br>
>From this thread:<br>
<a href="https://forum.nginx.org/read.php?2,271372,271380#msg-271380" rel="noreferrer" target="_blank">https://forum.nginx.org/read.<wbr>php?2,271372,271380#msg-271380</a><br>
<br>
I understand that the correct way to forward the HTTP method is to use named<br>
location.<br>
I am unable to find documentation on how this should be done.<br>
I tried the following:<br>
<br>
def view(self, req, resp):<br>
        name = get_dbname(<a href="http://req.user.id" rel="noreferrer" target="_blank">req.user.id</a>)<br>
        resp.set_header('X-Accel-<wbr>Redirect', '@resource'  )<br>
<br>
but this redirects to @resource /<br>
I would like to redirect to @resource /name<br></blockquote><div><br></div><div>Hi,</div><div><br></div><div>Here what you do. As you can not use X-Accel-Redirect to set different location, you should set other header with location and in nginx config do something like this:</div><div><br></div><div>location @resources {</div><div><div>    set $stored_real_location $upstream_http_x_real_location;</div><div>    proxy_pass <a href="http://resources-backend">http://resources-backend</a>$stored_real_location;</div></div><div>}</div><div><br></div><div>In example above Python code should set the following headers:</div><div><br></div><div>X-Accel-Redirect: @resources<br></div><div>X-Real-Location: /some/other/path...</div><div><br></div><div>Does it help?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,271448,271448#msg-271448" rel="noreferrer" target="_blank">https://forum.nginx.org/read.<wbr>php?2,271448,271448#msg-271448</a><br>
<br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Руслан Закиров</div><div>Руководитель отдела разработки веб-сервисов</div><div><span>+7(916) 597-92-69</span>, <span>ruz @ <a href="http://www.sports.ru/" target="_blank"><img src="http://farm7.static.flickr.com/6235/6210250811_19a888dbba_o.jpg" width="43" height="14" style="vertical-align: bottom; margin-right: 0px;"></a></span></div></div></div>
</div></div>