Grafana: Difference between revisions
simply explanation of setting up subpath / subdomain |
expand the deployment section |
||
Line 25: | Line 25: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/ Grafana's documentation for the options in <code>settings</code>.] | |||
== Usage == | |||
Grafana can be used through tunnels, like a SSH tunnel, or a VPN tunnel like Wireguard or Headscale. This way, Grafana can be completely shielded from the outside. | |||
Another way is to make it publicly available, usually behind a reverse proxy. | |||
==== Nginx ==== | |||
Here is how to setup [[Nginx]] such that it proxies <code>your.domain/grafana</code> to your Grafana instance: | |||
<syntaxhighlight lang=nix> | <syntaxhighlight lang=nix> | ||
services.nginx.virtualHosts."your.domain" = { | services.nginx.virtualHosts."your.domain" = { | ||
Line 36: | Line 44: | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | |||
==== Traefik ==== | |||
[[Traefik]] is another common reverse proxy, for which the configuration relevant to Grafana would like this:<syntaxhighlight lang="nix" line="1"> | |||
services.traefik = { | |||
# ... | |||
dynamicConfigOptions = { | |||
http.routers."your.domain" = { | |||
rule = "Host(`your.domain`) && PathPrefix(`/grafana`)"; | |||
service = "grafana"; | |||
} | |||
http.services."grafana" = { | |||
loadBalancer.servers = [ { | |||
url = "http://${toString config.services.grafana.settings.server.http_addr}:${toString config.services.grafana.settings.server.http_port}"; | |||
} ] | |||
}; | |||
# ... | |||
}; | |||
</syntaxhighlight>Alternatively, to use Grafana on <code>grafana.your.domain</code> instead of <code>your.domain/grafana</code>, you could change line 5 above to:<syntaxhighlight lang="diff"> | |||
-rule = "Host(`your.domain`) && PathPrefix(`/grafana`)"; | |||
+rule = "Host(`grafana.your.domain`)"; | |||
</syntaxhighlight> | </syntaxhighlight> | ||