From 3830a890ab42b35cd4da9991edef47b3c832cbdc Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sun, 3 Apr 2016 10:58:34 +0000 Subject: [PATCH] nginx module: add option to make vhost default --- nixos/modules/services/web-servers/nginx/default.nix | 7 ++++--- .../modules/services/web-servers/nginx/vhost-options.nix | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index d4c7cb08eef9..e912434e6b00 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -77,7 +77,8 @@ let let ssl = vhost.enableSSL || vhost.forceSSL; port = if vhost.port != null then vhost.port else (if ssl then 443 else 80); - listenString = toString port + optionalString ssl " ssl spdy"; + listenString = toString port + optionalString ssl " ssl spdy" + + optionalString vhost.default " default"; acmeLocation = optionalString vhost.enableACME '' location /.well-known/acme-challenge { try_files $uri @acme-fallback; @@ -92,8 +93,8 @@ let in '' ${optionalString vhost.forceSSL '' server { - listen 80; - listen [::]:80; + listen 80 ${optionalString vhost.default "default"}; + listen [::]:80 ${optionalString vhost.default "default"}; server_name ${serverName} ${concatStringsSep " " vhost.serverAliases}; ${acmeLocation} diff --git a/nixos/modules/services/web-servers/nginx/vhost-options.nix b/nixos/modules/services/web-servers/nginx/vhost-options.nix index 61868d8890d4..d684d7c1ff62 100644 --- a/nixos/modules/services/web-servers/nginx/vhost-options.nix +++ b/nixos/modules/services/web-servers/nginx/vhost-options.nix @@ -80,6 +80,14 @@ with lib; ''; }; + default = mkOption { + type = types.bool; + default = false; + description = '' + Makes this vhost the default. + ''; + }; + extraConfig = mkOption { type = types.lines; default = "";