fix(openresty): correct gzip defaults and add http.d for managed http directives - #9230
Draft
Snrat wants to merge 2 commits into
Draft
fix(openresty): correct gzip defaults and add http.d for managed http directives#9230Snrat wants to merge 2 commits into
Snrat wants to merge 2 commits into
Conversation
Introduce `conf/http.d/`, a directory reserved for http-context directives that 1Panel generates and owns, mounted read-only into the container. `conf/modules-enabled/` cannot serve this purpose: it is included at the top level of nginx.conf because `load_module` is a main-context directive, so http-context directives such as `brotli on` cannot be placed there. The include is emitted before `conf.d/*.conf` so that per-site configuration continues to take precedence over panel-managed global defaults. `upgrade.sh` injects the include into existing installations, mirroring the handling already in place for the modules-enabled include. It is idempotent and degrades to a warning when the conf.d include is absent, which happens when a user has heavily customised nginx.conf.
These defaults have been unchanged since 1.21.4.3 and no longer match how sites are actually served. gzip_types was missing application/json, so JSON API responses were served uncompressed. For an API-backed site this is the single largest loss in the whole configuration. Also add ld+json, text/xml, xhtml+xml, rss+xml, atom+xml, wasm, svg+xml and ttf/otf, all of which compress well. Already compressed formats (images, woff2, archives) are deliberately excluded. gzip_comp_level 2 -> 5. Level 2 gives up roughly 8-15% ratio on text compared to level 5, which sits at the cost/ratio knee for gzip. gzip_proxied expired|no-cache|no-store|private|auth -> any. The previous value only compressed proxied responses carrying those specific Cache-Control semantics, so a common upstream response such as `Cache-Control: public, max-age=3600` matched no condition and was never compressed. This affected reverse-proxy sites, one of the main use cases. Drop gzip_disable "MSIE [1-6]\." — a per-request User-Agent regex for browsers with no measurable traffic share. gzip_static is intentionally not enabled: nginx does not verify that a `.gz` file is newer than its source, so a stale precompressed file would be served indefinitely with no error. The module stays compiled in and can be enabled per site by users who generate `.gz` artifacts at build time.
wanghe-fit2cloud
marked this pull request as draft
August 26, 2026 06:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Body
Applies to
1.31.1.1-2-4-nobleonly. Older versions ship neithermodule.catalog.jsonnorDockerfile.modules, songinxModuleDynamicSupportedreturns false for them and they cannot use dynamic modules at all.
Companion PR: 1Panel-dev/1Panel#13639. This one must be merged first —
without the include added here, the files the panel writes to
conf/http.dare never loaded. The panel probes for the directory and stays inert when it is
missing, so merging out of order degrades silently rather than breaking.
1. gzip defaults
These values have been unchanged since 1.21.4.3 and no longer match how sites
are served today.
gzip_typesapplication/jsongzip_comp_level25gzip_proxiedexpired no-cache no-store private authanyCache-Control: public, max-age=3600matched no condition and was never compressed — this affected reverse-proxy sites, one of the main use cases.gzip_disable"MSIE [1-6]\."Already compressed formats (images other than SVG, woff/woff2, archives, media)
are deliberately excluded: recompressing them costs CPU and usually grows the
payload.
gzip_staticis intentionally not enabled. nginx does not verify that a.gzfile is newer than its source, so a stale artifact would be servedindefinitely with no error. The module stays compiled in and can be enabled
per site by users who generate
.gzat build time.2.
conf/http.dA directory for http-context directives that 1Panel generates and owns,
mounted read-only into the container.
conf/modules-enabledcannot serve this purpose:load_moduleis amain-context directive, so that directory is included at the top level of
nginx.conf and cannot host http-context directives such as
brotli on.The include is emitted before
conf.d/*.confso per-site configurationkeeps overriding these panel-managed globals.
upgrade.shinjects the include into existing installations, mirroring thehandling already in place for the modules-enabled include. It is idempotent
and degrades to a warning when the
conf.dinclude is absent, which happenswhen a user has heavily customised nginx.conf.
Testing
Verified against the real image with a real
ngx_brotli.so, compiled usingthis repo's own
Dockerfile.modules.init.shcreatesconf/http.d;nginx -tpasses; includeordering confirmed (
http.dat line 48,conf.dat 49).matching indentation; idempotent across three consecutive runs;
nginx -tpasses; every unrelated line preserved.
HTML page: 9042 B → 146 B.
38 assertions across the fresh-install and upgrade suites, all passing.