+++ title = "Running Grafana behind a reverse proxy" description = "Guide for running Grafana behind a reverse proxy" keywords = ["grafana", "nginx", "documentation", "haproxy", "reverse"] type = "docs" [menu.docs] name = "Running Grafana behind a reverse proxy" parent = "tutorials" weight = 1 +++
It should be straight forward to get Grafana up and running behind a reverse proxy. But here are some things that you might run into.
Links and redirects will not be rendered correctly unless you set the server.domain setting.
[server]
domain = foo.bar
To use sub path ex http://foo.bar/grafana make sure to include /grafana in the end of root_url.
Otherwise Grafana will not behave correctly. See example below.
Here are some example configurations for running Grafana behind a reverse proxy.
[server]
domain = foo.bar
server {
listen 80;
root /usr/share/nginx/www;
index index.html index.htm;
location / {
proxy_pass http://localhost:3000/;
}
}
[server]
domain = foo.bar
root_url = %(protocol)s://%(domain)s:/grafana
server {
listen 80;
root /usr/share/nginx/www;
index index.html index.htm;
location /grafana/ {
proxy_pass http://localhost:3000/;
}
}
IIS requires that the URL Rewrite module is installed.
Given:
grafanahttp://localhost:3000server config:
[server]
domain = localhost:8080
root_url = %(protocol)s://%(domain)s:/grafana
Create an Inbound Rule for the parent website (localhost:8080 in this example) with the following settings:
grafana(/)?(.*)Ignore case checkboxhttp://localhost:3000/{R:2}Append query string checkboxStop processing of subsequent rules checkboxThe rewrite rule that is generated for the web.config:
<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>