Input Headers. - headers_more_module.

David J david at styleflare.com
Fri Aug 31 19:28:58 UTC 2012


OK I can use that method.
I prefer it.

Thank you very much for this solution. I am very excited to learn a little
bit of LUA to.
On Aug 31, 2012 2:15 PM, "agentzh" <agentzh at gmail.com> wrote:

> Hello!
>
> On Fri, Aug 31, 2012 at 9:12 AM, David | StyleFlare
> <david at styleflare.com> wrote:
> > Strangely
> >
> > I still dont see the header variable set.
> >
> > I installed nginx-lua and I added the snippet you sent me to the nginx
> > config.
> >
>
> Sorry, ngx.location.capture disables nginx variable sharing between
> subrequests and their parent by default (for safety reasons). You need
> to explicitly allow that for your variable:
>
>     ngx.location.capture("/auth", { share_all_vars = true })
>
> See the official documentation of ngx_lua for more details:
>
>     http://wiki.nginx.org/HttpLuaModule#ngx.location.capture
>
> But it's highly recommended to use the response body and/or headers
> (instead of nginx variables) to return data from the subrequest back
> to its parent, for example:
>
>     location / {
>         access_by_lua '
>             local res = ngx.location.capture("/auth")
>             if res.status == 200 and res.body then
>                 ngx.req.set_header("X-Server-ID", res.body)
>             end
>         ';
>
>         uwsgi_pass ...;
>     }
>
>     location = /auth {
>         internal;
>         postgres_query "select server_id from ...";
>         postgres_pass backend;
>         postgres_output  value 0 0;
>     }
>
> That is, we use the postgres_output directive instead of postgres_set
> in location /auth here so that the server ID data will be returned as
> the subrequest's response body.
>
> Best regards,
> -agentzh
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120831/f8f8b164/attachment.html>


More information about the nginx mailing list