reverse proxy stuff

This commit is contained in:
mjallen18
2025-09-09 20:41:37 -05:00
parent 6567bb1348
commit f58006cf8a
14 changed files with 433 additions and 27 deletions

View File

@@ -12,6 +12,14 @@ let
hostAddress = "10.0.1.3";
actualUserId = config.users.users.nix-apps.uid;
actualGroupId = config.users.groups.jallen-nas.gid;
# Create reverse proxy configuration using mkReverseProxy
reverseProxyConfig = lib.${namespace}.mkReverseProxy {
name = "actual";
subdomain = cfg.reverseProxy.subdomain;
url = "http://${cfg.localAddress}:${toString cfg.port}";
middlewares = cfg.reverseProxy.middlewares;
};
in
{
imports = [ ./options.nix ];
@@ -98,19 +106,23 @@ in
};
};
services.traefik.dynamicConfigOptions = lib.mkIf cfg.reverseProxy.enable {
services.actual.loadBalancer.servers = [
{
url = "http://${cfg.localAddress}:${toString cfg.port}";
}
];
routers.actual = {
entryPoints = [ "websecure" ];
rule = "Host(`${cfg.reverseProxy.host}`)";
service = "actual";
middlewares = cfg.reverseProxy.middlewares;
tls.certResolver = "letsencrypt";
};
# services.traefik.dynamicConfigOptions = lib.mkIf cfg.reverseProxy.enable {
# services.actual.loadBalancer.servers = [
# {
# url = "http://${cfg.localAddress}:${toString cfg.port}";
# }
# ];
# routers.actual = {
# entryPoints = [ "websecure" ];
# rule = "Host(`${cfg.reverseProxy.host}`)";
# service = "actual";
# middlewares = cfg.reverseProxy.middlewares;
# tls.certResolver = "letsencrypt";
# };
# };
${namespace}.services.traefik = lib.mkIf cfg.reverseProxy.enable {
reverseProxies = [ reverseProxyConfig ];
};
networking = {

View File

@@ -1,6 +1,6 @@
{ lib, namespace, ... }:
let
inherit (lib.${namespace}) mkOpt mkBoolOpt;
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
in
with lib;
{
@@ -13,13 +13,6 @@ with lib;
dataDir = mkOpt types.str "" "Path to the data dir";
reverseProxy = {
enable = mkBoolOpt false "Enable reverse proxy support";
host = mkOpt types.str "" "Address of the proxy";
middlewares = with types; mkOpt (listOf str) [ ] "List of middlewares to use";
};
reverseProxy = mkReverseProxyOpt;
};
}