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 { locations = mkOption {
type = types.attrsOf (types.submodule { type = types.attrsOf (types.submodule {
options = { 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 { port = mkOption {
type = types.int; type = types.int;
description = "The port number for the location."; description = "The port number for the location.";
@ -111,10 +127,13 @@ in
locations = mapAttrs locations = mapAttrs
(path: location: { (path: location: {
proxyPass = "http://127.0.0.1:${toString location.port}"; proxyPass = "http://127.0.0.1:${toString location.port}";
proxyWebsockets = location.proxyWebsockets;
extraConfig = '' extraConfig = ''
${optionalString location.allowLan "deny 10.0.0.1;"}
${concatMapStringsSep "\n" (denyCIDR: "deny ${denyCIDR};") location.deny} ${concatMapStringsSep "\n" (denyCIDR: "deny ${denyCIDR};") location.deny}
${concatMapStringsSep "\n" (allowCIDR: "allow ${allowCIDR};") location.allow} ${concatMapStringsSep "\n" (allowCIDR: "allow ${allowCIDR};") location.allow}
''; ${optionalString location.allowLan ''allow ${config.architect.networks."lan".net};''}
'' + location.extraConfig;
}) })
conf.locations; conf.locations;
}) })