From 288d66541c25516a6cee5c9fb42af5f834f7ba28 Mon Sep 17 00:00:00 2001
From: Anthony Ryan <anthonyryan1@gmail.com>
Date: Wed, 3 Sep 2025 16:54:10 -0400
Subject: [PATCH] Explicitly define filters chain order, with modules which
 need to execute before and after mod_zip

Possible fix for #90 when compiled as a dynamic module.

This also eliminates the need to compile addition, slice or ssi when
building this module dynamically.since we're now explicitly defining
the postpone ordering.

Unforutnately, I don't believe the we can explicitly define filter
chain ordering in static modules, it may be possible to fix it by
reordering --add-module in configure, or by editing nginx build files
but that's out of our scope as a plugin.
---
 README.markdown | 2 +-
 config          | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/README.markdown b/README.markdown
index d3f381a..a0a628f 100644
--- a/README.markdown
+++ b/README.markdown
@@ -24,7 +24,7 @@ To install, compile nginx with the following option:
 
 * nginx 1.10.0 or later is required
 * (optional) to enable the `X-Archive-Charset` header, libiconv is required
-* http_postpone must be enabled by including at least one of the http_addition, http_slice or http_ssi modules
+* http_postpone must be enabled by including at least one of the http_addition, http_slice or http_ssi modules when using `--add-module` instead of `--add-dynamic-module`
 
 
 Usage
diff --git a/config b/config
index f782bd4..0516789 100644
--- a/config
+++ b/config
@@ -4,6 +4,10 @@ if [ $ngx_module_link = DYNAMIC ] ; then
     ngx_module_name=ngx_http_zip_module
     ngx_module_srcs="$ngx_addon_dir/ngx_http_zip_module.c $ngx_addon_dir/ngx_http_zip_parsers.c $ngx_addon_dir/ngx_http_zip_file.c $ngx_addon_dir/ngx_http_zip_headers.c"
 
+    ngx_module_type=HTTP_FILTER
+    # ensure we run after postpone (and after gunzip if relevant), but before copy
+    ngx_module_order="ngx_http_postpone_filter_module ngx_http_gunzip_filter_module $ngx_module_name ngx_http_copy_filter_module"
+
     . auto/module
 elif [ $ngx_module_link = ADDON ] ; then
     HTTP_AUX_FILTER_MODULES="$HTTP_AUX_FILTER_MODULES ngx_http_zip_module"
