[NGINX](https://www.nginx.com) is a high performance load balancer, web server, and reverse proxy.
@ -129,7 +115,7 @@ server {
}
```
If your Grafana configuration does not set `serve_from_sub_path` to true then you need to add a rewrite rule to each location block:
Add a rewrite rule to each location block:
```
rewrite ^/grafana/(.*) /$1 break;
@ -139,7 +125,7 @@ If your Grafana configuration does not set `serve_from_sub_path` to true then yo
If Grafana is being served from behind a NGINX proxy with TLS termination enabled, then the `root_url` should be set accordingly. For example, if Grafana is being served from `https://example.com/grafana` then the `root_url` should be set to `https://example.com/grafana/` or `https://%(domain)s/grafana/` (and the corresponding `domain` should be set to `example.com`) in the `server` section of the Grafana configuration file. The `protocol` setting should be set to `http`, because the TLS handshake is being handled by NGINX.
{{% /admonition %}}
## Configure HAProxy
### Configure HAProxy
To configure HAProxy to serve Grafana under a _sub path_:
@ -150,22 +136,15 @@ frontend http-in
backend grafana_backend
server grafana localhost:3000
```
If your Grafana configuration doesn't set `server.serve_from_sub_path` to `true`, then you must add a rewrite rule to the `backend grafana_backend` block:
## Alternative for serving Grafana under a sub path
**Warning:** You only need this, if you do not handle the sub path serving via your reverse proxy configuration.
If you don't want or can't use the reverse proxy to handle serving Grafana from a _sub path_, you can set the config variable `server_from_sub_path` to `true`.
1. Include the sub path at the end of the `root_url`.
2. Set `serve_from_sub_path` to `true`:
In this tutorial you learned how to run Grafana behind a reverse proxy.