On Thu, Aug 30, 2012 at 10:12 AM, David | StyleFlare [email protected] wrote:
uwsgi_pass://upstream;
}
I see X-Server-ID sent in the response headers, but my upstream application
does not seem to get the Header Variable.
The more_set_input_headers directive runs at the end of the nginx
“rewrite” phase and I think your $id variable just didn’t have a value
(yet) at that phase.
You can try inserting a constant header like this:
set $id "My-ID";
more_set_input_headers "X-Server-ID: $id";
I’ve tested the following example with nginx 1.2.3 and ngx_headers_more
0.18:
On Thu, Aug 30, 2012 at 1:12 PM, David | StyleFlare [email protected] wrote:
Thank You
So this worked.
Cool
When is $pg_server actually set?
Are you using the ngx_http_auth_request module? The auth_request
directive runs at the access phase. The order of running phases in
nginx for any nginx locations always looks like this:
On Fri, Aug 31, 2012 at 9:12 AM, David | StyleFlare [email protected] 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:
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.