Grafana: Difference between revisions

imported>PaulGrandperrin
m fix proxyPath url, a slash was missing at the end causing redirection loop
imported>ShortCord
m Config structure update for Grafana
Line 8: Line 8:


<syntaxhighlight lang=nix>
<syntaxhighlight lang=nix>
services.grafana = {
services.grafana =
      enable = true;
  enable = true;
       # Listening address and TCP port
  settings = {
       addr = "127.0.0.1";
    server = {
       port = 3000;
       # Listening Address
       # Grafana needs to know on which domain and URL it's running:
       http_addr = "127.0.0.1";
       # and Port
      http_port = 3000;
       # Grafana needs to know on which domain and URL it's running
       domain = "your.domain";
       domain = "your.domain";
       rootUrl = "https://your.domain/grafana/"; # Not needed if it is `https://your.domain/`
       root_url = "https://your.domain/grafana/"; # Not needed if it is `https://your.domain/`
    };
  };
};
};
</syntaxhighlight>
</syntaxhighlight>
Line 21: Line 26:
This will make Grafana available only at localhost. On a server, it might be used through SSH tunnel or made publicly available using nginx with TLS. For example the follwing [[Nginx]] configuration can be used:
This will make Grafana available only at localhost. On a server, it might be used through SSH tunnel or made publicly available using nginx with TLS. For example the follwing [[Nginx]] configuration can be used:
<syntaxhighlight lang=nix>
<syntaxhighlight lang=nix>
  services.nginx.virtualHosts."your.domain" = {
services.nginx.virtualHosts."your.domain" = {
    addSSL = true;
  addSSL = true;
    enableACME = true;
  enableACME = true;
    locations."/grafana/" = {
  locations."/grafana/" = {
        proxyPass = "http://127.0.0.1:${toString config.services.grafana.port}/";
      proxyPass = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}/";
        proxyWebsockets = true;
      proxyWebsockets = true;
    };
   };
   };
};
</syntaxhighlight>
</syntaxhighlight>