Setting headers within process_headers function of module

Maxim Dounin mdounin at
Thu Jun 6 11:24:11 UTC 2013


On Thu, Jun 06, 2013 at 05:17:14PM +1000, Atul Bhouraskar wrote:

> Hi,
> I am writing an "upstream" module to implement a custom protocol. I
> have managed to get most of it working end to end by following the
> fastcgi module code but am stuck at a problem that should be
> simple...
> I need to set certain HTTP headers within the process_header
> function as the upstream server does not speak HTTP. The two headers
> that I am most interested in at this time are "X-Accel-Redirect" and
> "Content-Type" (populated at different times depending upon content
> received from upstream). The values of both headers are available in
> the function.
> I have tried following the example at
> (substituting headers_out
> with headers_in) with no luck, the output headers don't seem to
> change or there is a math exception thrown when a nginx internal
> function is performing a hash lookup. Looking at the fastcgi module
> it seems that there might be some hash initialisation that is
> needed? I haven't been able to figure this out.

>From your description it's not clear what exactly fails for you, 
but I would assume it's hide_headers_hash lookup, which should be 
initialized using the ngx_http_upstream_hide_headers_hash() 

Maxim Dounin

More information about the nginx-devel mailing list