2023-01-28 01:53:50 +08:00
---
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
aliases:
- /docs/grafana/latest/installation/behind_proxy/
authors:
- grafana_labs
categories:
- administration
2023-01-28 01:53:50 +08:00
description: Learn how to run Grafana behind a reverse proxy
id: run-grafana-behind-a-proxy
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- enterprise
- oss
2023-01-28 01:53:50 +08:00
status: Published
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
summary: Learn how to run Grafana behind a reverse proxy
tags:
- advanced
title: Run Grafana behind a reverse proxy
2023-01-28 01:53:50 +08:00
---
## Introduction
In this tutorial, you'll configure Grafana to run behind a reverse proxy.
When running Grafana behind a proxy, you need to configure the domain name to let Grafana know how to render links and redirects correctly.
- In the Grafana configuration file, change `server.domain` to the domain name you'll be using:
```bash
[server]
domain = example.com
```
2024-03-20 02:54:25 +08:00
- Restart Grafana for the changes to take effect.
2023-01-28 01:53:50 +08:00
2024-02-20 21:18:32 +08:00
## Configure reverse proxy
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
### Configure nginx
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
[nginx ](https://www.nginx.com ) is a high performance load balancer, web server, and reverse proxy.
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
- In your nginx configuration file inside the `http` section, add the following:
2023-01-28 01:53:50 +08:00
```nginx
2024-03-20 02:54:25 +08:00
# This is required to proxy Grafana Live WebSocket connections.
2023-01-28 01:53:50 +08:00
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream grafana {
server localhost:3000;
}
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
2024-03-20 02:54:25 +08:00
proxy_set_header Host $host;
2023-01-28 01:53:50 +08:00
proxy_pass http://grafana;
}
2024-03-20 02:54:25 +08:00
# Proxy Grafana Live WebSocket connections.
2023-01-28 01:53:50 +08:00
location /api/live/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
2024-03-20 02:54:25 +08:00
proxy_set_header Host $host;
2023-01-28 01:53:50 +08:00
proxy_pass http://grafana;
}
}
```
2024-03-20 02:54:25 +08:00
- Reload the nginx configuration.
- Navigate to port 80 on the machine nginx is running on.
You're greeted by the Grafana login page.
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
For Grafana Live which uses WebSocket connections you may have to raise the nginx value for [`worker_connections` ](https://nginx.org/en/docs/ngx_core_module.html#worker_connections ) option which is `512` by default. The default value limits the number of possible concurrent connections with Grafana Live.
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
Also, be aware that the preceding configuration only works when the `proxy_pass` value for `location /` is a literal string.
If you want to use a variable here, you must instead use [a rewrite rule ](https://www.nginx.com/blog/creating-nginx-rewrite-rules/ ).
For more information, refer to [the GitHub issue #18299 ](https://github.com/grafana/grafana/issues/18299 ).
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
To configure nginx to serve Grafana under a _sub path_ , update the `location` block:
2023-01-28 01:53:50 +08:00
```nginx
2024-03-20 02:54:25 +08:00
# This is required to proxy Grafana Live WebSocket connections.
2023-01-28 01:53:50 +08:00
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream grafana {
server localhost:3000;
}
server {
listen 80;
root /usr/share/nginx/www;
index index.html index.htm;
location /grafana/ {
2024-03-20 02:54:25 +08:00
proxy_set_header Host $host;
2023-01-28 01:53:50 +08:00
proxy_pass http://grafana;
}
# Proxy Grafana Live WebSocket connections.
location /grafana/api/live/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
2024-03-20 02:54:25 +08:00
proxy_set_header Host $host;
2023-01-28 01:53:50 +08:00
proxy_pass http://grafana;
}
}
```
2024-02-20 21:18:32 +08:00
Add a rewrite rule to each location block:
2023-05-17 18:18:24 +08:00
```
rewrite ^/grafana/(.*) /$1 break;
```
2024-03-20 02:54:25 +08:00
{{< admonition type = "note" > }}
If nginx is performing TLS termination, then you must set the `root_url` and `protocol` configuration accordingly.
If you're serving Grafana from `https://example.com/grafana/` then the `root_url` is `https://example.com/grafana/` or `https://%(domain)s/grafana/` with the corresponding `domain` configuration value set to `example.com` in the `server` section of the Grafana configuration file.
Set `protocol` to `http` .
{{< / admonition > }}
2023-07-11 23:29:26 +08:00
2024-02-20 21:18:32 +08:00
### Configure HAProxy
2023-01-28 01:53:50 +08:00
To configure HAProxy to serve Grafana under a _sub path_ :
```bash
frontend http-in
bind *:80
use_backend grafana_backend if { path /grafana } or { path_beg /grafana/ }
backend grafana_backend
2024-01-30 07:30:57 +08:00
server grafana localhost:3000
2024-02-20 21:18:32 +08:00
# Requires haproxy >= 1.6
http-request set-path %[path,regsub(^/grafana/?,/)]
# Works for haproxy < 1.6
# reqrep ^([^\ ]*\ /)grafana[/]?(.*) \1\2
2023-01-28 01:53:50 +08:00
server grafana localhost:3000
```
2024-02-20 21:18:32 +08:00
### Configure IIS
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
{{< admonition type = "note" > }}
To use IIS, you must have the URL Rewrite module installed.
{{< / admonition > }}
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
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:
2023-01-28 01:53:50 +08:00
- 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
2024-03-20 02:54:25 +08:00
This is the rewrite rule that's generated in the `web.config` :
2023-01-28 01:53:50 +08:00
```xml
< rewrite >
< rules >
< rule name = "Grafana" enabled = "true" stopProcessing = "true" >
< match url = "grafana(/)?(.*)" / >
< action type = "Rewrite" url = "http://localhost:3000/{R:2}" logRewrittenUrl = "false" / >
< / rule >
< / rules >
< / rewrite >
```
2024-03-20 02:54:25 +08:00
For more detailed instruction, refer to the [tutorial on IIS URL Rewrites ](/tutorials/iis/ ).
2023-01-28 01:53:50 +08:00
2024-02-20 21:18:32 +08:00
### Configure Traefik
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
[Traefik ](https://traefik.io/traefik/ ) Cloud Native application proxy.
2023-01-28 01:53:50 +08:00
2024-03-20 02:54:25 +08:00
Using the Docker provider and the following labels configures the router and service for a domain or subdomain routing.
2023-01-28 01:53:50 +08:00
```yaml
labels:
traefik.http.routers.grafana.rule: Host(`grafana.example.com`)
traefik.http.services.grafana.loadbalancer.server.port: 3000
```
2024-03-20 02:54:25 +08:00
To deploy on a _sub path_ :
2023-01-28 01:53:50 +08:00
```yaml
labels:
traefik.http.routers.grafana.rule: Host(`example.com`) & & PathPrefix(`/grafana`)
traefik.http.services.grafana.loadbalancer.server.port: 3000
```
Examples using the file provider.
```yaml
http:
routers:
grafana:
rule: Host(`grafana.example.com`)
service: grafana
services:
grafana:
loadBalancer:
servers:
- url: http://192.168.30.10:3000
```
```yaml
http:
routers:
grafana:
rule: Host(`example.com`) & & PathPrefix(`/grafana`)
service: grafana
services:
grafana:
loadBalancer:
servers:
- url: http://192.168.30.10:3000
```
2024-02-20 21:18:32 +08:00
## Alternative for serving Grafana under a sub path
2024-03-20 02:54:25 +08:00
{{< admonition type = "note" > }}
You only need this if you don't handle the sub path serving via your reverse proxy configuration.
{{< / admonition > }}
2024-02-20 21:18:32 +08:00
2024-03-20 02:54:25 +08:00
If you don't want or can't use the reverse proxy to handle serving Grafana from a _sub path_ , you can set the configuration variable `server_from_sub_path` to `true` .
2024-02-20 21:18:32 +08:00
1. Include the sub path at the end of the `root_url` .
2024-03-20 02:54:25 +08:00
1. Set `serve_from_sub_path` to `true` :
2023-01-28 01:53:50 +08:00
2024-02-20 21:18:32 +08:00
```bash
[server]
domain = example.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
serve_from_sub_path = true
```