Filter 那么nginx总是为每个请求遍历相同的过滤器集?

Filter 那么nginx总是为每个请求遍历相同的过滤器集?,filter,nginx,Filter,Nginx,我知道nginx模块被编译成nginx二进制文件,而不是动态链接的 这是否意味着无论发生什么情况,上述13个过滤器都将在每个请求上执行?是。这是真的。例如,下面是来自gzip模块的init函数。但不要太担心,因为如果大多数过滤器不适用,它们会提前退出 &ngx_http_write_filter_module, &ngx_http_header_filter_module, &ngx_http_chunked_filter_module, &ngx_http_ra

我知道nginx模块被编译成nginx二进制文件,而不是动态链接的


这是否意味着无论发生什么情况,上述13个过滤器都将在每个请求上执行?

是。这是真的。例如,下面是来自gzip模块的init函数。但不要太担心,因为如果大多数过滤器不适用,它们会提前退出

&ngx_http_write_filter_module,
&ngx_http_header_filter_module,
&ngx_http_chunked_filter_module,
&ngx_http_range_header_filter_module,
&ngx_http_gzip_filter_module,
&ngx_http_postpone_filter_module,
&ngx_http_ssi_filter_module,
&ngx_http_charset_filter_module,
&ngx_http_userid_filter_module,
&ngx_http_headers_filter_module,
&ngx_http_copy_filter_module,
&ngx_http_range_body_filter_module,
&ngx_http_not_modified_filter_module,
static ngx_int_t ngx_http_gzip_filter_init(ngx_conf_t *cf)
{
    ngx_http_next_header_filter = ngx_http_top_header_filter;
    ngx_http_top_header_filter = ngx_http_gzip_header_filter;

    ngx_http_next_body_filter = ngx_http_top_body_filter;
    ngx_http_top_body_filter = ngx_http_gzip_body_filter;

    return NGX_OK;
}