From 94a2cba8d9a89036965089e4d9eb963d422ff93c Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sat, 15 Apr 2017 15:09:18 +0200 Subject: [PATCH] nginx module: add resolver config --- .../services/web-servers/nginx/default.nix | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index c5ba8eb147cf..2f691b0e9df9 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -38,6 +38,10 @@ let include ${cfg.package}/conf/fastcgi.conf; include ${cfg.package}/conf/uwsgi_params; + ${optionalString (cfg.resolver.addresses != []) '' + resolver ${toString cfg.resolver.addresses} ${optionalString (cfg.resolver.valid != "") "valid=${cfg.resolver.valid}"}; + ''} + ${optionalString (cfg.recommendedOptimisation) '' # optimisation sendfile on; @@ -385,6 +389,32 @@ in description = "Path to DH parameters file."; }; + resolver = mkOption { + type = types.submodule { + options = { + addresses = mkOption { + type = types.listOf types.str; + default = []; + example = literalExample ''[ "[::1]" "127.0.0.1:5353" ]''; + description = "List of resolvers to use"; + }; + valid = mkOption { + type = types.str; + default = ""; + example = "30s"; + description = '' + By default, nginx caches answers using the TTL value of a response. + An optional valid parameter allows overriding it + ''; + }; + }; + }; + description = '' + Configures name servers used to resolve names of upstream servers into addresses + ''; + default = {}; + }; + virtualHosts = mkOption { type = types.attrsOf (types.submodule (import ./vhost-options.nix { inherit config lib;