nginx module: add option to make vhost default

This commit is contained in:
Robin Gloster 2016-04-03 10:58:34 +00:00
parent 138945500e
commit 3830a890ab
2 changed files with 12 additions and 3 deletions

View File

@ -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}

View File

@ -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 = "";