Merge branch 'master' of gum:stockholm

This commit is contained in:
makefu 2016-03-16 08:25:50 +01:00
commit 57476fb24a

View File

@ -12,6 +12,20 @@ let
api = { api = {
enable = mkEnableOption "krebs.nginx"; enable = mkEnableOption "krebs.nginx";
default404 = mkOption {
type = types.bool;
default = true;
description = ''
By default all requests not directed to an explicit hostname are
replied with a 404 error to avoid accidental exposition of nginx
services.
Set this value to `false` to disable this behavior - you will then be
able to configure a new `default_server` in the listen address entries
again.
'';
};
servers = mkOption { servers = mkOption {
type = types.attrsOf (types.submodule { type = types.attrsOf (types.submodule {
options = { options = {
@ -20,6 +34,7 @@ let
# TODO use identity # TODO use identity
default = [ default = [
"${config.networking.hostName}" "${config.networking.hostName}"
"${config.networking.hostName}.r"
"${config.networking.hostName}.retiolum" "${config.networking.hostName}.retiolum"
]; ];
}; };
@ -53,17 +68,19 @@ let
sendfile on; sendfile on;
keepalive_timeout 65; keepalive_timeout 65;
gzip on; gzip on;
server {
listen 80 default_server; ${optionalString cfg.default404 ''
server_name _; server {
return 404; listen 80 default_server;
} server_name _;
return 404;
}''}
${concatStrings (mapAttrsToList (_: to-server) cfg.servers)} ${concatStrings (mapAttrsToList (_: to-server) cfg.servers)}
''; '';
}; };
}; };
indent = replaceChars ["\n"] ["\n "]; indent = replaceChars ["\n"] ["\n "];
to-location = { name, value }: '' to-location = { name, value }: ''