From 0a9f3b827d4e41038a7621199ee790812d4758c3 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Wed, 13 Dec 2023 20:50:43 +0100 Subject: Configure Grafana to be run behind a reverse proxy --- tw/services/grafana.scm | 9 +++++---- tw/services/web.scm | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tw') diff --git a/tw/services/grafana.scm b/tw/services/grafana.scm index 2fdb9695..051aa72b 100644 --- a/tw/services/grafana.scm +++ b/tw/services/grafana.scm @@ -42,12 +42,13 @@ variables.")) (shell (file-append shadow "/sbin/nologin"))))) (define (grafana-environment config) - (match-record config (bind-address host-port) - (mixed-text-file "grafana.env" "\ + (match-record config (domain bind-address host-port) + (plain-file "grafana.env" (string-append "\ # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ GF_SERVER_PROTOCOL=http +GF_SERVER_DOMAIN=" domain " GF_SERVER_HTTP_ADDR=" bind-address " -GF_SERVER_HTTP_PORT=" host-port " +GF_SERVER_HTTP_PORT=" (number->string host-port) " # gzip compression is recommended by docs, but is not the default GF_SERVER_ENABLE_GZIP=true GF_ANALYTICS_REPORTING_ENABLED=false @@ -59,7 +60,7 @@ GF_SNAPSHOTS_ENABLED=false GF_DATE_FORMATS_INTERVAL_HOUR=DD.MM. HH:mm GF_DATE_FORMATS_INTERVAL_DAY=DD.MM. # TODO: https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#smtp -"))) +")))) (define (grafana-docker-service config) (match-record config (container data-path metrics-credentials-file) diff --git a/tw/services/web.scm b/tw/services/web.scm index 0372b906..835aebd3 100644 --- a/tw/services/web.scm +++ b/tw/services/web.scm @@ -43,7 +43,9 @@ speaks. Set to @code{\"https\"} if you want to proxy HTTPS-to-HTTPS.")) (list (nginx-location-configuration (uri "/") (body `(("proxy_pass http://" ,destination-ip ":" - ,(number->string destination-port) ";"))))))))) + ,(number->string destination-port) ";") + ;; For Grafana: https://grafana.com/tutorials/run-grafana-behind-a-proxy/#configure-nginx + "proxy_set_header Host $http_host;")))))))) (define (reverse-proxy-certificates configs) (map reverse-proxy-certificate configs)) -- cgit v1.2.3