Hello!
On Fri, Sep 14, 2012 at 5:26 AM, James Hurst <
ja...@riverratrecords.com> wrote:
> I'm using subrequests to proxy to an upstream origin server, and allowing
> the main request headers to be sent through. In certain cases, I need to
> modify the request by adding a validator, like "If-Modified-Since" for
> example... see "Unspecificied end-to-end revalidation":
>
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.4.
>
> I can't see a way to do this though? I noticed there is now a set_header()
> function, but this doesn't affect sub requests. I tried setting
> "http_if_modified_since" in "vars" for the call to ngx.location.capture(),
> but this just complains that I'm setting an undefined variable.
>
For now there's several work-around, see:
http://groups.google.com/group/openresty/browse_thread/thread/59d2c011dd366cc3/52e0055013a5e63a
(This thread is in Chinese, you need to use Google Translate or other things.)
Basically it is just
1. set the parent request's request header before calling
ngx.location.capture so that the subrequest will inherit it,
or 2. use proxy_set_header to set the header directly in your
subrequest location:
http://wiki.nginx.org/HttpProxyModule#proxy_set_header
In the option 2, you may need to pass the header value to the
subrequest by means of nginx variables or something like that.
> Do we need a "header" table for ngx.location.capture()? Or perhaps an option
> for set_header(include_subrequests?)?
>
There's a pending pull request from vadim-pavlov that adds an
"extra_headers" option to ngx.location.capture and its friends:
https://github.com/chaoslawful/lua-nginx-module/pull/139
I'm always looking for the time to tweak and merge it :)
Best regards,
-agentzh