1
0

unify compressable mime types across modules

also improve template expansion
This commit is contained in:
Konstantin Demin 2024-07-17 12:16:51 +03:00
parent a747fbe080
commit 9ca1528f41
Signed by: krd
GPG Key ID: 4D56F87A8BA65FD0
10 changed files with 65 additions and 74 deletions

View File

@ -1,24 +0,0 @@
## default is 6
brotli_comp_level 5;
## default is 512k
brotli_window 64k;
brotli_min_length 1024;
brotli_buffers 32 16k;
brotli_types
application/atom+xml
application/javascript
application/json
application/vnd.api+json
application/rss+xml
application/x-javascript
application/xhtml+xml
application/xml
image/svg+xml
image/x-icon
text/css
text/javascript
text/plain
text/xml
;

View File

@ -0,0 +1,14 @@
{%- from 'mime-types.compress.j2inc' import mime_types with context -%}
## default is 6
brotli_comp_level 5;
## default is 512k
brotli_window 64k;
brotli_min_length 1024;
brotli_buffers 32 16k;
brotli_types
## sourced from mime-types.compress.txt
{{ mime_types | indent(4) }}
;

View File

@ -1,25 +0,0 @@
## default is 1
gzip_comp_level 2;
gzip_min_length 1024;
gzip_buffers 32 16k;
gzip_vary on;
gzip_proxied any;
gzip_types
application/atom+xml
application/javascript
application/json
application/vnd.api+json
application/rss+xml
application/x-javascript
application/xhtml+xml
application/xml
image/svg+xml
image/x-icon
text/css
text/javascript
text/plain
text/xml
;

View File

@ -0,0 +1,15 @@
{%- from 'mime-types.compress.j2inc' import mime_types with context -%}
## default is 1
gzip_comp_level 2;
gzip_min_length 1024;
gzip_buffers 32 16k;
gzip_vary on;
gzip_proxied any;
gzip_types
## sourced from mime-types.compress.txt
{{ mime_types | indent(4) }}
;

View File

@ -1,22 +0,0 @@
## default is 1
zstd_comp_level 2;
zstd_min_length 1024;
zstd_buffers 32 16k;
zstd_types
application/atom+xml
application/javascript
application/json
application/vnd.api+json
application/rss+xml
application/x-javascript
application/xhtml+xml
application/xml
image/svg+xml
image/x-icon
text/css
text/javascript
text/plain
text/xml
;

View File

@ -0,0 +1,12 @@
{%- from 'mime-types.compress.j2inc' import mime_types with context -%}
## default is 1
zstd_comp_level 2;
zstd_min_length 1024;
zstd_buffers 32 16k;
zstd_types
## sourced from mime-types.compress.txt
{{ mime_types | indent(4) }}
;

View File

@ -0,0 +1,2 @@
{%- set mime_file = pathlib.Path(os.path.join(os.getenv('NGX_MERGED_ROOT'), 'snip/mime-types.compress.txt')) -%}
{%- set mime_types = mime_file.read_text() -%}

View File

@ -0,0 +1,14 @@
application/atom+xml
application/javascript
application/json
application/vnd.api+json
application/rss+xml
application/x-javascript
application/xhtml+xml
application/xml
image/svg+xml
image/x-icon
text/css
text/javascript
text/plain
text/xml

View File

@ -5,6 +5,8 @@ set -f
[ "${NGX_STRICT_LOAD}" = 0 ] || set -e
export NGX_MERGED_ROOT="${merged_root}"
expand_error() {
[ "${expand_error_seen:-}" = 1 ] || log_always 'template expansion has failed'
expand_error_seen=1
@ -19,12 +21,15 @@ expand_error() {
dirs='conf mod modules njs site snip'
[ "${NGX_PROCESS_STATIC}" = 0 ] || dirs="${dirs} static"
merge_dirs=
for n in ${dirs} ; do
merged_dir="${merged_root}/$n"
[ -d "${merged_dir}" ] || continue
expand_dir_envsubst "${merged_dir}/" || expand_error
expand_dir_jinja "${merged_dir}/" || expand_error
merge_dirs="${merge_dirs} ${merged_dir}/"
done
expand_dir_envsubst ${merge_dirs} || expand_error
expand_dir_jinja ${merge_dirs} || expand_error
exit 0

View File

@ -9,7 +9,7 @@ import jinja2
ME = sys.argv[0]
J2_MODULES_DEFAULT = 'os os.path sys netaddr psutil re wcmatch'
J2_MODULES_DEFAULT = 'os os.path sys netaddr pathlib psutil re wcmatch'
J2_SUFFIX = '.j2'
J2_CFG_PATHS = [
'/angie/j2cfg',