Skip to content

Commit

Permalink
nixos/nginx: add recommendedZstdSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Feb 22, 2023
1 parent dd73b3e commit 5e5a84b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions nixos/modules/services/web-servers/nginx/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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};
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 5e5a84b

Please sign in to comment.