From 2aa3d871849c82d040dafb7611b6a6fec52cf617 Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Sun, 11 May 2025 18:40:49 -0700 Subject: [PATCH] router: services: caddy subpath proxies for grafana and adguardhome --- hosts/router/services.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/hosts/router/services.nix b/hosts/router/services.nix index d530340..95b0755 100644 --- a/hosts/router/services.nix +++ b/hosts/router/services.nix @@ -30,7 +30,11 @@ in # https://wiki.nixos.org/wiki/Grafana#Declarative_configuration services.grafana = { enable = true; - settings.server.http_port = 3001; + settings.server = { + http_port = 3001; + serve_from_sub_path = true; + root_url = "%(protocol)s://%(domain)s:%(http_port)s/grafana/"; + }; provision = { enable = true; datasources.settings.datasources = [ @@ -46,8 +50,18 @@ in services.caddy = { enable = true; virtualHosts."grouter.${domain}".extraConfig = '' - reverse_proxy localhost:${toString config.services.grafana.settings.server.http_port} tls internal + @grafana path /grafana /grafana/* + handle @grafana { + reverse_proxy localhost:${toString config.services.grafana.settings.server.http_port} + } + redir /adghome /adghome/ + handle_path /adghome/* { + reverse_proxy localhost:${toString config.services.adguardhome.port} + basic_auth { + Bob $2a$14$HsWmmzQTN68K3vwiRAfiUuqIjKoXEXaj9TOLUtG2mO1vFpdovmyBy + } + } ''; }; }