nginx module: add option to make vhost default

+12 -3
+4 -3
nixos/modules/services/web-servers/nginx/default.nix
··· 77 77 let 78 78 ssl = vhost.enableSSL || vhost.forceSSL; 79 79 port = if vhost.port != null then vhost.port else (if ssl then 443 else 80); 80 - listenString = toString port + optionalString ssl " ssl spdy"; 80 + listenString = toString port + optionalString ssl " ssl spdy" 81 + + optionalString vhost.default " default"; 81 82 acmeLocation = optionalString vhost.enableACME '' 82 83 location /.well-known/acme-challenge { 83 84 try_files $uri @acme-fallback; ··· 92 93 in '' 93 94 ${optionalString vhost.forceSSL '' 94 95 server { 95 - listen 80; 96 - listen [::]:80; 96 + listen 80 ${optionalString vhost.default "default"}; 97 + listen [::]:80 ${optionalString vhost.default "default"}; 97 98 98 99 server_name ${serverName} ${concatStringsSep " " vhost.serverAliases}; 99 100 ${acmeLocation}
+8
nixos/modules/services/web-servers/nginx/vhost-options.nix
··· 80 80 ''; 81 81 }; 82 82 83 + default = mkOption { 84 + type = types.bool; 85 + default = false; 86 + description = '' 87 + Makes this vhost the default. 88 + ''; 89 + }; 90 + 83 91 extraConfig = mkOption { 84 92 type = types.lines; 85 93 default = "";