Accessing custom upstream proxy header

Good morning,

Using ngx_http_request_t, how can I access a custom upstream header
within a
module, for example:

r->upstream->headers_in->xxx_my_header->value

No matter what I try, it doesn’t appear to be working

  • Peter

Posted at Nginx Forum:

Hello!

On Mon, Dec 17, 2012 at 03:05:51PM -0500, preinde wrote:

Good morning,

Using ngx_http_request_t, how can I access a custom upstream header within a
module, for example:

r->upstream->headers_in->xxx_my_header->value

No matter what I try, it doesn’t appear to be working

Obviously enough the r->upstream->headers_in structure won’t
contain any specific members for your custom header unless you
patch nginx.

If you want to search for a custom header within a module, you
have to iterate though &r->upstream->headers_in.headers list. See
e.g. ngx_http_upstream_header_variable() and
ngx_http_variable_unknown_header(), used to implement
$upstream_http_* variables.


Maxim D.