vhost: added attributes

This commit is contained in:
Giulio De Pasquale 2023-06-05 03:02:02 +02:00
parent 9aeacafbb2
commit 65ba588d8e

View File

@ -75,6 +75,22 @@ in
locations = mkOption {
type = types.attrsOf (types.submodule {
options = {
extraConfig = mkOption {
type = types.str;
description = "Extra configuration for the location.";
default = "";
};
allowLan = mkOption {
type = types.bool;
default = false;
};
proxyWebsockets = mkOption {
type = types.bool;
default = false;
};
port = mkOption {
type = types.int;
description = "The port number for the location.";
@ -111,10 +127,13 @@ in
locations = mapAttrs
(path: location: {
proxyPass = "http://127.0.0.1:${toString location.port}";
proxyWebsockets = location.proxyWebsockets;
extraConfig = ''
${optionalString location.allowLan "deny 10.0.0.1;"}
${concatMapStringsSep "\n" (denyCIDR: "deny ${denyCIDR};") location.deny}
${concatMapStringsSep "\n" (allowCIDR: "allow ${allowCIDR};") location.allow}
'';
${optionalString location.allowLan ''allow ${config.architect.networks."lan".net};''}
'' + location.extraConfig;
})
conf.locations;
})