From 65ba588d8ea3faf73dfd35db771348609efd75ce Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Mon, 5 Jun 2023 03:02:02 +0200 Subject: [PATCH] vhost: added attributes --- hosts/architect/options.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hosts/architect/options.nix b/hosts/architect/options.nix index 8f807b6..90642d3 100644 --- a/hosts/architect/options.nix +++ b/hosts/architect/options.nix @@ -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; })