diff --git a/confs/global/gzip.conf b/confs/global/gzip.conf deleted file mode 100644 index e858fc1..0000000 --- a/confs/global/gzip.conf +++ /dev/null @@ -1,9 +0,0 @@ -# /etc/nginx/gzip.conf - -# enable/disable gzip compression -gzip %USE_GZIP%; -gzip_comp_level %GZIP_COMP_LEVEL%; -gzip_disable msie6; -gzip_min_length %GZIP_MIN_LENGTH%; -gzip_proxied any; -gzip_types %GZIP_TYPES%; diff --git a/confs/site/gzip.conf b/confs/site/gzip.conf new file mode 100644 index 0000000..f0f77fc --- /dev/null +++ b/confs/site/gzip.conf @@ -0,0 +1,4 @@ +gzip on; +gzip_comp_level %GZIP_COMP_LEVEL%; +gzip_min_length %GZIP_MIN_LENGTH%; +gzip_types %GZIP_TYPES%; diff --git a/confs/site/server.conf b/confs/site/server.conf index 469e95f..5d884a5 100644 --- a/confs/site/server.conf +++ b/confs/site/server.conf @@ -1,7 +1,7 @@ server { %SERVER_CONF% - %MAIN_LUA% %PROXY_REAL_IP% + %MAIN_LUA% %USE_MODSECURITY% %LISTEN_HTTP% %USE_HTTPS% @@ -32,4 +32,5 @@ server { %ERRORS% %USE_FAIL2BAN% %USE_CLIENT_CACHE% + %USE_GZIP% } diff --git a/entrypoint/defaults.sh b/entrypoint/defaults.sh index 49c80bb..0748875 100644 --- a/entrypoint/defaults.sh +++ b/entrypoint/defaults.sh @@ -12,10 +12,10 @@ CACHE="${CACHE-max=1000 inactive=60s}" CACHE_ERRORS="${CACHE_ERRORS-on}" CACHE_USES="${CACHE_USES-1}" CACHE_VALID="${CACHE_VALID-60s}" -USE_GZIP="${USE_GZIP-off}" -GZIP_COMP_LEVEL="${GZIP_COMP_LEVEL-6}" -GZIP_MIN_LENGTH="${GZIP_MIN_LENGTH-10240}" -GZIP_TYPES="${GZIP_TYPES-text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml}" +USE_GZIP="${USE_GZIP-no}" +GZIP_COMP_LEVEL="${GZIP_COMP_LEVEL-5}" +GZIP_MIN_LENGTH="${GZIP_MIN_LENGTH-1000}" +GZIP_TYPES="${GZIP_TYPES-text/css text/javascript application/json image/svg+xml text/plain application/xml text/xml}" REMOTE_PHP_PATH="${REMOTE_PHP_PATH-/app}" HEADER_SERVER="${HEADER_SERVER-no}" X_FRAME_OPTIONS="${X_FRAME_OPTIONS-DENY}" diff --git a/entrypoint/global-config.sh b/entrypoint/global-config.sh index 378e813..fc9e9d3 100644 --- a/entrypoint/global-config.sh +++ b/entrypoint/global-config.sh @@ -38,10 +38,6 @@ replace_in_file "/etc/nginx/cache.conf" "%CACHE%" "$CACHE" replace_in_file "/etc/nginx/cache.conf" "%CACHE_ERRORS%" "$CACHE_ERRORS" replace_in_file "/etc/nginx/cache.conf" "%CACHE_USES%" "$CACHE_USES" replace_in_file "/etc/nginx/cache.conf" "%CACHE_VALID%" "$CACHE_VALID" -replace_in_file "/etc/nginx/gzip.conf" "%USE_GZIP%" "$USE_GZIP" -replace_in_file "/etc/nginx/gzip.conf" "%GZIP_COMP_LEVEL%" "$GZIP_COMP_LEVEL" -replace_in_file "/etc/nginx/gzip.conf" "%GZIP_MIN_LENGTH%" "$GZIP_MIN_LENGTH" -replace_in_file "/etc/nginx/gzip.conf" "%GZIP_TYPES%" "$GZIP_TYPES" # let's encrypt setup if [ "$AUTO_LETS_ENCRYPT" = "yes" ] ; then diff --git a/entrypoint/site-config.sh b/entrypoint/site-config.sh index 2d74d35..e330bbc 100644 --- a/entrypoint/site-config.sh +++ b/entrypoint/site-config.sh @@ -47,6 +47,16 @@ else replace_in_file "${NGINX_PREFIX}server.conf" "%USE_CLIENT_CACHE%" "" fi +# gzip compression +if [ "$USE_GZIP" = "yes" ] ; then + replace_in_file "${NGINX_PREFIX}server.conf" "%USE_GZIP%" "include ${NGINX_PREFIX}gzip.conf;" + replace_in_file "${NGINX_PREFIX}gzip.conf" "%GZIP_COMP_LEVEL%" "$GZIP_COMP_LEVEL" + replace_in_file "${NGINX_PREFIX}gzip.conf" "%GZIP_MIN_LENGTH%" "$GZIP_MIN_LENGTH" + replace_in_file "${NGINX_PREFIX}gzip.conf" "%GZIP_TYPES%" "$GZIP_TYPES" +else + replace_in_file "${NGINX_PREFIX}server.conf" "%USE_GZIP%" "" +fi + # remote PHP if [ "$REMOTE_PHP" != "" ] ; then replace_in_file "${NGINX_PREFIX}server.conf" "%USE_PHP%" "include ${NGINX_PREFIX}php.conf;"