004-vps-migration #5
@@ -5,25 +5,6 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
proxyReverseServices = [
|
||||
"bazarr"
|
||||
"firefox-syncserver"
|
||||
"flame"
|
||||
"flameSecret"
|
||||
"isso"
|
||||
"kavita"
|
||||
"linkwarden"
|
||||
"maloja"
|
||||
"mealie"
|
||||
"metube"
|
||||
"microbin"
|
||||
"multi-scrobbler"
|
||||
"nix-serve"
|
||||
"plausible"
|
||||
"shiori"
|
||||
"vaultwarden"
|
||||
"yamtrack"
|
||||
];
|
||||
proxyReverseFixServices = [
|
||||
"atticd"
|
||||
"audiobookshelf"
|
||||
@@ -41,8 +22,7 @@ let
|
||||
mkServiceConfig =
|
||||
type: services: lib.listToAttrs (map (name: lib.nameValuePair name { inherit type; }) services);
|
||||
standardProxyServices =
|
||||
(mkServiceConfig "proxyReverse" proxyReverseServices)
|
||||
// (mkServiceConfig "proxyReverseFix" proxyReverseFixServices)
|
||||
(mkServiceConfig "proxyReverseFix" proxyReverseFixServices)
|
||||
// (mkServiceConfig "proxyReversePrivate" proxyReversePrivateServices);
|
||||
generateProxyConfig =
|
||||
serviceName: serviceConfig:
|
||||
@@ -59,9 +39,20 @@ let
|
||||
throw "Unknown proxy type: ${serviceConfig.type}";
|
||||
in
|
||||
lib.nameValuePair cfg.host (lib.mkIf cfg.enableProxy (proxyFunc cfg));
|
||||
standardProxyNames = builtins.attrNames standardProxyServices;
|
||||
customProxyServices =
|
||||
config.my.servers
|
||||
|> lib.filterAttrs (
|
||||
name: srv:
|
||||
(srv.enableProxy or false)
|
||||
&& !(builtins.elem name standardProxyNames)
|
||||
)
|
||||
|> lib.mapAttrs (name: _srv: { type = "proxyReverse"; });
|
||||
in
|
||||
{
|
||||
config = lib.mkIf config.my.enableProxy {
|
||||
services.nginx.virtualHosts = lib.mapAttrs' generateProxyConfig standardProxyServices;
|
||||
services.nginx.virtualHosts = lib.mapAttrs' generateProxyConfig (
|
||||
standardProxyServices // customProxyServices
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user