diff options
author | Izorkin <izorkin@elven.pw> | 2022-10-28 19:42:35 +0300 |
---|---|---|
committer | Izorkin <izorkin@elven.pw> | 2022-11-01 10:07:38 +0300 |
commit | c09fd120cc056a324559aa8fcc9184968c9d0713 (patch) | |
tree | 05f64cdc396ec19ffd6d5754b90ac2ba128b145d /nixos/modules/services/web-servers/nginx/default.nix | |
parent | 544c526393f15c946a77ed0f6f11f5d3b90e50b8 (diff) | |
download | nixlib-c09fd120cc056a324559aa8fcc9184968c9d0713.tar nixlib-c09fd120cc056a324559aa8fcc9184968c9d0713.tar.gz nixlib-c09fd120cc056a324559aa8fcc9184968c9d0713.tar.bz2 nixlib-c09fd120cc056a324559aa8fcc9184968c9d0713.tar.lz nixlib-c09fd120cc056a324559aa8fcc9184968c9d0713.tar.xz nixlib-c09fd120cc056a324559aa8fcc9184968c9d0713.tar.zst nixlib-c09fd120cc056a324559aa8fcc9184968c9d0713.zip |
nixos/nginx: add proxyCache options
Diffstat (limited to 'nixos/modules/services/web-servers/nginx/default.nix')
-rw-r--r-- | nixos/modules/services/web-servers/nginx/default.nix | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 9cbac370612f..b74803e619fb 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -192,6 +192,14 @@ let server_tokens ${if cfg.serverTokens then "on" else "off"}; + ${optionalString (cfg.proxyCache.enable) '' + proxy_cache_path /var/cache/nginx keys_zone=${cfg.proxyCache.keysZoneName}:${cfg.proxyCache.keysZoneSize} + levels=${cfg.proxyCache.levels} + use_temp_path=${if cfg.proxyCache.useTempPath then "on" else "off"} + inactive=${cfg.proxyCache.inactive} + max_size=${cfg.proxyCache.maxSize}; + ''} + ${cfg.commonHttpConfig} ${vhosts} @@ -689,6 +697,72 @@ in ''; }; + proxyCache = mkOption { + type = types.submodule { + options = { + enable = mkEnableOption (lib.mdDoc "Enable proxy cache"); + + keysZoneName = mkOption { + type = types.str; + default = "cache"; + example = "my_cache"; + description = lib.mdDoc "Set name to shared memory zone."; + }; + + keysZoneSize = mkOption { + type = types.str; + default = "10m"; + example = "32m"; + description = lib.mdDoc "Set size to shared memory zone."; + }; + + levels = mkOption { + type = types.str; + default = "1:2"; + example = "1:2:2"; + description = lib.mdDoc '' + The levels parameter defines structure of subdirectories in cache: from + 1 to 3, each level accepts values 1 or 2. Сan be used any combination of + 1 and 2 in these formats: x, x:x and x:x:x. + ''; + }; + + useTempPath = mkOption { + type = types.bool; + default = false; + example = true; + description = lib.mdDoc '' + Nginx first writes files that are destined for the cache to a temporary + storage area, and the use_temp_path=off directive instructs Nginx to + write them to the same directories where they will be cached. Recommended + that you set this parameter to off to avoid unnecessary copying of data + between file systems. + ''; + }; + + inactive = mkOption { + type = types.str; + default = "10m"; + example = "1d"; + description = lib.mdDoc '' + Cached data that has not been accessed for the time specified by + the inactive parameter is removed from the cache, regardless of + its freshness. + ''; + }; + + maxSize = mkOption { + type = types.str; + default = "1g"; + example = "2048m"; + description = lib.mdDoc "Set maximum cache size"; + }; + }; + }; + default = {}; + description = lib.mdDoc "Configure proxy cache"; + }; + resolver = mkOption { type = types.submodule { options = { |