about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2016-04-03 10:58:34 +0000
committerRobin Gloster <mail@glob.in>2016-07-28 11:59:13 +0000
commit3830a890ab42b35cd4da9991edef47b3c832cbdc (patch)
tree7d3b0df14e78321acd6c1325e1a46c8d00dd692d /nixos
parent138945500ee71eaac71435a78f627f9c83d035f4 (diff)
downloadnixlib-3830a890ab42b35cd4da9991edef47b3c832cbdc.tar
nixlib-3830a890ab42b35cd4da9991edef47b3c832cbdc.tar.gz
nixlib-3830a890ab42b35cd4da9991edef47b3c832cbdc.tar.bz2
nixlib-3830a890ab42b35cd4da9991edef47b3c832cbdc.tar.lz
nixlib-3830a890ab42b35cd4da9991edef47b3c832cbdc.tar.xz
nixlib-3830a890ab42b35cd4da9991edef47b3c832cbdc.tar.zst
nixlib-3830a890ab42b35cd4da9991edef47b3c832cbdc.zip
nginx module: add option to make vhost default
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/web-servers/nginx/default.nix7
-rw-r--r--nixos/modules/services/web-servers/nginx/vhost-options.nix8
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 = "";