Proxy : Why two places request structure is stored in upstream

Maxim Dounin mdounin at
Mon Nov 24 13:00:14 UTC 2014


On Sat, Nov 22, 2014 at 01:44:06PM +0530, punit kandoi wrote:

> Hi,
> I was reading world famous tutorial by Emiller. Nginx guide to module
> development.
> I was going to ngx_http_proxy_handler() as described in tutorial.
> I seen request structure is stored in two places in upstream.
>     u->pipe->input_filter = ngx_http_proxy_copy_filter;
>     u->pipe->input_ctx = r;  <<------
>     u->input_filter_init = ngx_http_proxy_input_filter_init;
>     u->input_filter = ngx_http_proxy_non_buffered_copy_filter;
>     u->input_filter_ctx = r;   <<------
> Whats the difference between two variables?

The "u->pipe->input_ctx" context is for ngx_event_pipe() code, to 
be used by buffered input filters when needed.

The "u->input_filter_ctx" context is for non-buffered filters.

> If we want to take request structure from upstream in later stage before
> selecting server which value to be used?

Both of the above are wrong if you aren't writing an input filter.

Maxim Dounin

More information about the nginx-devel mailing list