use grafana socket

This commit is contained in:
XenGi 2026-08-03 11:35:08 +02:00
commit 5487171476
Signed by: xengi
SSH key fingerprint: SHA256:jxWM2RTHvxxcncXycwwWkP7HCWb4VREN05UGJTbIPZg

View file

@ -3,6 +3,9 @@
# Dashboards: # Dashboards:
# - Synapse: https://github.com/element-hq/synapse/tree/master/contrib/grafana # - Synapse: https://github.com/element-hq/synapse/tree/master/contrib/grafana
let
fqdn = "monitoring.${config.networking.domain}";
in
{ {
imports = [ imports = [
../../services/nginx.nix ../../services/nginx.nix
@ -13,7 +16,13 @@
grafana = { grafana = {
enable = true; enable = true;
settings = { settings = {
server.http_addr = "::1"; server = {
domain = fqdn;
enable_gzip = true;
enforce_domain = true;
root_url = "https://${fqdn}:443/";
protocol = "socket";
};
database = { database = {
type = "postgres"; type = "postgres";
name = "grafana"; name = "grafana";
@ -26,6 +35,13 @@
admin_user = "xengi"; admin_user = "xengi";
admin_password = "$__file{${config.age.secrets.grafana_admin_password.path}}"; admin_password = "$__file{${config.age.secrets.grafana_admin_password.path}}";
admin_email = "cccb-grafana@xengi.de"; admin_email = "cccb-grafana@xengi.de";
cookie_samesite = "strict";
cookie_secure = true;
disable_gravatar = true;
#strict_transport_security = true;
#strict_transport_security_preload = true;
#strict_transport_security_subdomains = true;
#x_xss_protection = true;
}; };
analytics = { analytics = {
reporting_enabled = false; reporting_enabled = false;
@ -49,10 +65,7 @@
}; };
}; };
nginx = { nginx.virtualHosts."monitoring.${config.networking.domain}" = {
upstreams."grafana".servers."[${config.services.grafana.settings.server.http_addr}]:${toString config.services.grafana.settings.server.http_port}" =
{ };
virtualHosts."monitoring.${config.networking.domain}" = {
default = true; default = true;
quic = true; quic = true;
kTLS = true; kTLS = true;
@ -67,16 +80,15 @@
locations = { locations = {
"/" = { "/" = {
basicAuthFile = config.age.secrets.grafana_basic_auth.path; basicAuthFile = config.age.secrets.grafana_basic_auth.path;
proxyPass = "http://grafana"; proxyPass = "http://unix:/run/grafana/grafana.sock";
recommendedProxySettings = true; recommendedProxySettings = true;
}; };
"/api/live/" = { "/api/live/" = {
proxyPass = "http://grafana"; proxyPass = "http://unix:/run/grafana/grafana.sock";
recommendedProxySettings = true; recommendedProxySettings = true;
proxyWebsockets = true; proxyWebsockets = true;
}; };
}; };
}; };
}; };
};
} }