From fee854ed01d1df73fd64cf42d228697341b4377f Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Wed, 13 Mar 2019 17:29:13 +0000 Subject: [PATCH] nixos/nginx: add return option to location --- nixos/modules/services/web-servers/nginx/default.nix | 3 ++- .../services/web-servers/nginx/location-options.nix | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index cfd7c8f4e5bf..9f9e080bd92c 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -276,6 +276,7 @@ let ${optionalString (config.tryFiles != null) "try_files ${config.tryFiles};"} ${optionalString (config.root != null) "root ${config.root};"} ${optionalString (config.alias != null) "alias ${config.alias};"} + ${optionalString (config.return != null) "return ${config.return};"} ${config.extraConfig} ${optionalString (config.proxyPass != null && cfg.recommendedProxySettings) "include ${recommendedProxyConfig};"} } @@ -373,7 +374,7 @@ in preStart = mkOption { type = types.lines; default = '' - test -d ${cfg.stateDir}/logs || mkdir -m 750 -p ${cfg.stateDir}/logs + test -d ${cfg.stateDir}/logs || mkdir -m 750 -p ${cfg.stateDir}/logs test `stat -c %a ${cfg.stateDir}` = "750" || chmod 750 ${cfg.stateDir} test `stat -c %a ${cfg.stateDir}/logs` = "750" || chmod 750 ${cfg.stateDir}/logs chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir} diff --git a/nixos/modules/services/web-servers/nginx/location-options.nix b/nixos/modules/services/web-servers/nginx/location-options.nix index 9b44433d3845..aeb9b1dd79ef 100644 --- a/nixos/modules/services/web-servers/nginx/location-options.nix +++ b/nixos/modules/services/web-servers/nginx/location-options.nix @@ -64,6 +64,15 @@ with lib; ''; }; + return = mkOption { + type = types.nullOr types.str; + default = null; + example = "301 http://example.com$request_uri;"; + description = '' + Adds a return directive, for e.g. redirections. + ''; + }; + extraConfig = mkOption { type = types.lines; default = "";