Install Grafana Behind reverse proxy

If the installation is done on a Host server then the following steps should be performed to setup grafana behind a reverse proxy.

Installation steps

  1. To let Grafana know how to render and redirect the links correctly, in the Grafana configuration file, change server.domain to the domain name that will be used,

[server]
domain = example.com

2. Restart grafana to see the changes

3. To serve grafana behind the sub path, such as http://example.com/grafana

Include the sub path at the end of the root_url.

Set serve_from_sub_path to true.

[server]
domain = example.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
serve_from_sub_path = true

4. Next step is to configure NGINX.

Configure NGINX

NGINX is a high performance load balancer, web server, and reverse proxy.

  • In the NGINX configuration file inside http section, add the following:

  • Reload the NGINX configuration

  • Navigate to port 80 on the machine NGINX is running on and the Grafana login page will appear.

For Grafana Live which uses WebSocket connections, raise a Nginx worker_connections option which is 512 by default – which limits the number of possible concurrent connections with Grafana Live.

To configure NGINX to serve Grafana under a sub path, update the location block:

Configure HAProxy

To configure HAProxy to serve Grafana under a sub path:

Configure IIS

To configure IIS to serve Grafana under a sub path, create an Inbound Rule for the parent website in IIS Manager with the following settings:

  • pattern: grafana(/)?(.*)

  • check the Ignore case checkbox

  • rewrite URL set to http://localhost:3000/{R:2}

  • check the Append query string checkbox

  • check the Stop processing of subsequent rules checkbox

This is the rewrite rule that is generated in the web.config:

Check the tutorial on IIS URL Rewrites for more in-depth instructions.

Configure Traefik

Traefik Cloud Native Reverse Proxy / Load Balancer / Edge Router

Using the docker provider the following labels will configure the router and service for a domain or subdomain routing.

To deploy a subpath

Examples using the file provider,

Last updated

Was this helpful?