aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2023-12-13 20:50:43 +0100
committerTimo Wilken2023-12-13 20:51:11 +0100
commit0a9f3b827d4e41038a7621199ee790812d4758c3 (patch)
tree20b2c002b4458648dffee0357a9fb3da3504b426
parentaa72ac94a3223faa287c01557874c3840219e000 (diff)
Configure Grafana to be run behind a reverse proxy
-rw-r--r--tw/services/grafana.scm9
-rw-r--r--tw/services/web.scm4
2 files changed, 8 insertions, 5 deletions
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 <grafana-configuration> (bind-address host-port)
- (mixed-text-file "grafana.env" "\
+ (match-record config <grafana-configuration> (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 <grafana-configuration> (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))