Welcome! Log In Create A New Profile

Advanced

Re: Setting headers within process_headers function of module

Atul Bhouraskar
June 06, 2013 07:44PM
On 06/06/13 21:24, Maxim Dounin wrote:
> Hello!
>
> 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
>> http://wiki.nginx.org/HeadersManagement (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()
> function.
>

Thanks! That was it. I basically followed the fastcgi module again:

static ngx_str_t ngx_http_fastcgi_hide_headers[] = {
ngx_string("Status"),
ngx_string("X-Accel-Expires"),
ngx_string("X-Accel-Redirect"),
ngx_string("X-Accel-Limit-Rate"),
ngx_string("X-Accel-Buffering"),
ngx_string("X-Accel-Charset"),
ngx_null_string
};

....

if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
&prev->upstream, ngx_http_fastcgi_hide_headers, &hash)
!= NGX_OK)
{
return NGX_CONF_ERROR;
}

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Setting headers within process_headers function of module

Atul Bhouraskar 716 June 06, 2013 03:18AM

Re: Setting headers within process_headers function of module

Maxim Dounin 268 June 06, 2013 07:26AM

Re: Setting headers within process_headers function of module

Atul Bhouraskar 370 June 06, 2013 07:44PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 181
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready