From 13183d3bde442c2ab91bac100734efaf6995b8ef Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 13 Apr 2022 14:04:45 -0700 Subject: grafana: the vhost is configurable --- modules/services/grafana/default.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'modules/services/grafana/default.nix') diff --git a/modules/services/grafana/default.nix b/modules/services/grafana/default.nix index 20d5a19..bcb52e2 100644 --- a/modules/services/grafana/default.nix +++ b/modules/services/grafana/default.nix @@ -5,6 +5,11 @@ let in { options.my.services.grafana = with lib; { enable = mkEnableOption "grafana observability stack"; + vhostName = mkOption { + type = types.str; + example = "dash.fcuny.net"; + description = "Name for the virtual host"; + }; }; config = lib.mkIf cfg.enable { @@ -27,16 +32,18 @@ in { }; }; - services.nginx.virtualHosts."dash.fcuny.xyz" = { + services.nginx.virtualHosts."${cfg.vhostName}" = { forceSSL = true; - useACMEHost = "dash.fcuny.xyz"; + useACMEHost = cfg.vhostName; locations."/" = { - proxyPass = "http://127.0.0.1:3000"; + proxyPass = "http://${config.services.grafana.addr}:${ + toString config.services.grafana.port + }"; proxyWebsockets = true; }; }; - security.acme.certs."dash.fcuny.xyz" = { + security.acme.certs."${cfg.vhostName}" = { dnsProvider = "gcloud"; credentialsFile = secrets."acme/credentials".path; }; -- cgit 1.4.1