infra/modules/nginx-prometheus-exporters/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
Nix
Raw Normal View History

2024-05-08 20:57:07 +00:00
{
config,
flake,
lib,
...
}:
2024-04-28 17:05:12 +00:00
let
# Find element in list config.services.matrix-synapse.settings.listeners
# that sets type = "metrics"
2024-05-08 20:57:07 +00:00
listenerWithMetrics =
lib.findFirst (listener: listener.type == "metrics")
(throw "Found no matrix-synapse.settings.listeners.*.type containing string metrics")
config.services.matrix-synapse.settings.listeners;
2024-04-28 17:05:12 +00:00
synapseMetricsPort = "${toString listenerWithMetrics.port}";
in
{
age.secrets.nachtigall-metrics-nginx-basic-auth = {
file = "${flake.self}/secrets/nachtigall-metrics-nginx-basic-auth.age";
mode = "600";
owner = "nginx";
};
services.nginx.virtualHosts = {
"nachtigall.${config.pub-solar-os.networking.domain}" = {
2024-04-28 17:05:12 +00:00
enableACME = true;
addSSL = true;
basicAuthFile = "${config.age.secrets.nachtigall-metrics-nginx-basic-auth.path}";
locations."/metrics" = {
2024-05-08 20:57:07 +00:00
proxyPass = "http://127.0.0.1:${toString (config.services.prometheus.exporters.node.port)}";
2024-04-28 17:05:12 +00:00
};
locations."/_synapse/metrics" = {
proxyPass = "http://127.0.0.1:${synapseMetricsPort}";
};
};
};
}