Skip to content

Commit f4ba115

Browse files
authored
bugfix: fix module order to avoid taking effect before other modules such as sub filter module (#31)
* bugfix: add module order to avoid taking effect before other modules such as sub filter module Module order is incorrect for compression module. For example, if using ngx_http_sub_module, string is not replaced because it it tries to replace content when it is already compressed. For this purpose, you need to add module sorting in config to adjust the order in which modules take effect.
1 parent 6be764e commit f4ba115

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

filter/config

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,39 @@ ngx_module_name=ngx_http_zstd_filter_module
106106
ngx_module_incs="$ngx_zstd_opt_I"
107107
ngx_module_srcs=$HTTP_ZSTD_SRCS
108108
ngx_module_libs=$NGX_LD_OPT
109+
ngx_module_order="$ngx_module_name \
110+
ngx_pagespeed \
111+
ngx_http_postpone_filter_module \
112+
ngx_http_ssi_filter_module \
113+
ngx_http_charset_filter_module \
114+
ngx_http_xslt_filter_module \
115+
ngx_http_image_filter_module \
116+
ngx_http_sub_filter_module \
117+
ngx_http_addition_filter_module \
118+
ngx_http_gunzip_filter_module \
119+
ngx_http_userid_filter_module \
120+
ngx_http_headers_filter_module \
121+
ngx_http_copy_filter_module \
122+
ngx_http_range_body_filter_module \
123+
ngx_http_not_modified_filter_module \
124+
ngx_http_slice_filter_module"
125+
109126
. auto/module
110127

128+
if [ "$ngx_module_link" != DYNAMIC ]; then
129+
# ngx_module_order doesn't work with static modules,
130+
# so we must re-order filters here.
131+
132+
if [ "$HTTP_GZIP" = YES ]; then
133+
next=ngx_http_gzip_filter_module
134+
elif echo $HTTP_FILTER_MODULES | grep pagespeed_etag_filter >/dev/null; then
135+
next=ngx_pagespeed_etag_filter
136+
else
137+
next=ngx_http_range_header_filter_module
138+
fi
139+
140+
HTTP_FILTER_MODULES=`echo $HTTP_FILTER_MODULES \
141+
| sed "s/$ngx_module_name//" \
142+
| sed "s/$next/$next $ngx_module_name/"`
143+
fi
144+

0 commit comments

Comments
 (0)