Welcome! Log In Create A New Profile

Advanced

Fixing ngx_http_slice_module use with named locations

Mindaugas Rasiukevicius
May 04, 2016 09:22AM
Hi,

There is a problem with ngx_http_slice_module when it is used together
with an internal redirection to a named location. It results in Nginx
workers caching incorrect content and spinning in an infinite loop.
Consider the following fragment:

location /foo {
error_page 550 = @bar;
return 550;
}
location @bar {
slice ...;
proxy_pass ...;
proxy_cache ...;
...
}

In ngx_http_slice_body_filter(), the slice context is associated with
the subrequest:

ngx_http_set_ctx(sr, ctx, ngx_http_slice_filter_module);

However, the location re-match is triggered for the subrequests trying
to fetch each slice. In the ngx_http_named_location() function:

/* clear the modules contexts */
ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);

So, the slice context gets lost. There are several ways to fix this.
Unless you want an API to preserve the context, one simple fix would be
to get the context via r->parent (if ctx == NULL && r != r->main).

What would be the preferred way to fix this?

Thanks.

--
Mindaugas

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

Fixing ngx_http_slice_module use with named locations

Mindaugas Rasiukevicius 486 May 04, 2016 09:22AM

Re: Fixing ngx_http_slice_module use with named locations

Mindaugas Rasiukevicius 304 May 11, 2016 11:46AM

Re: Fixing ngx_http_slice_module use with named locations

Roman Arutyunyan 187 February 16, 2017 10:46AM



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

Online Users

Guests: 216
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