about summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/nginx/default.nix
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2023-01-31 22:25:27 +0100
committerSandro Jäckel <sandro.jaeckel@sap.com>2023-02-22 13:59:53 +0100
commit5e5a84b193f66427d215fd1af2b2fd2400a5c84c (patch)
treeaa5030a737146e56b282db1cf64846d27ba3e6a3 /nixos/modules/services/web-servers/nginx/default.nix
parentdd73b3e57b46282b0d220fefa6c3970dcbaceb69 (diff)
downloadnixlib-5e5a84b193f66427d215fd1af2b2fd2400a5c84c.tar
nixlib-5e5a84b193f66427d215fd1af2b2fd2400a5c84c.tar.gz
nixlib-5e5a84b193f66427d215fd1af2b2fd2400a5c84c.tar.bz2
nixlib-5e5a84b193f66427d215fd1af2b2fd2400a5c84c.tar.lz
nixlib-5e5a84b193f66427d215fd1af2b2fd2400a5c84c.tar.xz
nixlib-5e5a84b193f66427d215fd1af2b2fd2400a5c84c.tar.zst
nixlib-5e5a84b193f66427d215fd1af2b2fd2400a5c84c.zip
nixos/nginx: add recommendedZstdSettings
Diffstat (limited to 'nixos/modules/services/web-servers/nginx/default.nix')
-rw-r--r--nixos/modules/services/web-servers/nginx/default.nix23
1 files changed, 21 insertions, 2 deletions
diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix
index bc5b4be51098..89fecc938cad 100644
--- a/nixos/modules/services/web-servers/nginx/default.nix
+++ b/nixos/modules/services/web-servers/nginx/default.nix
@@ -186,8 +186,8 @@ let
         brotli_types ${lib.concatStringsSep " " compressMimeTypes};
       ''}
 
-      # https://docs.nginx.com/nginx/admin-guide/web-server/compression/
       ${optionalString cfg.recommendedGzipSettings ''
+        # https://docs.nginx.com/nginx/admin-guide/web-server/compression/
         gzip on;
         gzip_static on;
         gzip_vary on;
@@ -197,6 +197,14 @@ let
         gzip_types ${lib.concatStringsSep " " compressMimeTypes};
       ''}
 
+      ${optionalString cfg.recommendedZstdSettings ''
+        zstd on;
+        zstd_comp_level 9;
+        zstd_min_length 256;
+        zstd_static on;
+        zstd_types ${lib.concatStringsSep " " compressMimeTypes};
+      ''}
+
       ${optionalString cfg.recommendedProxySettings ''
         proxy_redirect          off;
         proxy_connect_timeout   ${cfg.proxyTimeout};
@@ -492,6 +500,16 @@ in
         '';
       };
 
+      recommendedZstdSettings = mkOption {
+        default = false;
+        type = types.bool;
+        description = lib.mdDoc ''
+          Enable recommended zstd settings. Learn more about compression in Zstd format [here](https://github.com/tokers/zstd-nginx-module).
+
+          This adds `pkgs.nginxModules.zstd` to `services.nginx.additionalModules`.
+        '';
+      };
+
       proxyTimeout = mkOption {
         type = types.str;
         default = "60s";
@@ -1005,7 +1023,8 @@ in
       groups = config.users.groups;
     }) dependentCertNames;
 
-    services.nginx.additionalModules = optional cfg.recommendedBrotliSettings pkgs.nginxModules.brotli;
+    services.nginx.additionalModules = optional cfg.recommendedBrotliSettings pkgs.nginxModules.brotli
+      ++ lib.optional cfg.recommendedZstdSettings pkgs.nginxModules.zstd;
 
     systemd.services.nginx = {
       description = "Nginx Web Server";