How to modfiy headers in and headers out

Yingyuan Cheng yingyuan at
Wed Oct 31 11:03:17 MSK 2007

Hello all.

I want to write a balancer module to balance requests based on cookie.
In the phase of upstream_init_peer, I lookup special cookie from
headers_in.headers. If not found, I'll generate a new one, insert it
into headers_in.headers which would be packed to backend fastcgi
processes. After that, I need to modify headers_out.headers, so that the
newly generated cookie can be sent to clients.

The problem is I could't modfiy headers_out.headers in the phase of
upstream_init_peer. If I call ngx_list_push(&r->headers_out.headers),
there would be a segment fault. I ever tried to modify it in the header
filter phase, but the hook for filter and the hook for balancer seem not
working together.

Is there any way to work around?



More information about the nginx mailing list