monitoring02: add Caddy reverse proxy for VictoriaMetrics and vmalert
Add metrics.home.2rjus.net and vmalert.home.2rjus.net CNAMEs with Caddy TLS termination via internal ACME CA. Refactors Grafana's Caddy config from configFile to globalConfig + virtualHosts so both modules can contribute routes to the same Caddy instance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,7 @@
|
|||||||
role = "monitoring";
|
role = "monitoring";
|
||||||
};
|
};
|
||||||
|
|
||||||
# DNS CNAME for Grafana test instance
|
homelab.dns.cnames = [ "grafana-test" "metrics" "vmalert" ];
|
||||||
homelab.dns.cnames = [ "grafana-test" ];
|
|
||||||
|
|
||||||
# Enable Vault integration
|
# Enable Vault integration
|
||||||
vault.enable = true;
|
vault.enable = true;
|
||||||
|
|||||||
@@ -87,22 +87,20 @@
|
|||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.unstable.caddy;
|
package = pkgs.unstable.caddy;
|
||||||
configFile = pkgs.writeText "Caddyfile" ''
|
globalConfig = ''
|
||||||
{
|
acme_ca https://vault.home.2rjus.net:8200/v1/pki_int/acme/directory
|
||||||
acme_ca https://vault.home.2rjus.net:8200/v1/pki_int/acme/directory
|
metrics
|
||||||
metrics
|
'';
|
||||||
}
|
virtualHosts."grafana-test.home.2rjus.net".extraConfig = ''
|
||||||
|
log {
|
||||||
grafana-test.home.2rjus.net {
|
output file /var/log/caddy/grafana.log {
|
||||||
log {
|
mode 644
|
||||||
output file /var/log/caddy/grafana.log {
|
|
||||||
mode 644
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse_proxy http://127.0.0.1:3000
|
|
||||||
}
|
}
|
||||||
|
reverse_proxy http://127.0.0.1:3000
|
||||||
|
'';
|
||||||
|
# Metrics endpoint on plain HTTP for Prometheus scraping
|
||||||
|
extraConfig = ''
|
||||||
http://${config.networking.hostName}.home.2rjus.net/metrics {
|
http://${config.networking.hostName}.home.2rjus.net/metrics {
|
||||||
metrics
|
metrics
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,14 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Caddy reverse proxy for VictoriaMetrics and vmalert
|
||||||
|
services.caddy.virtualHosts."metrics.home.2rjus.net".extraConfig = ''
|
||||||
|
reverse_proxy http://127.0.0.1:8428
|
||||||
|
'';
|
||||||
|
services.caddy.virtualHosts."vmalert.home.2rjus.net".extraConfig = ''
|
||||||
|
reverse_proxy http://127.0.0.1:8880
|
||||||
|
'';
|
||||||
|
|
||||||
# Alertmanager - same config as monitoring01 but will only receive
|
# Alertmanager - same config as monitoring01 but will only receive
|
||||||
# alerts after cutover (vmalert notifier is disabled above)
|
# alerts after cutover (vmalert notifier is disabled above)
|
||||||
services.prometheus.alertmanager = {
|
services.prometheus.alertmanager = {
|
||||||
|
|||||||
Reference in New Issue
Block a user