Running Grafana behind a reverse proxy
Links and redirects will not be rendered correctly unless you set the server.domain setting.
Here are some example configurations for running Grafana behind a reverse proxy.
[server]
domain = foo.bar
Grafana configuration with sub path
[server]
domain = foo.bar
root_url = %(protocol)s://%(domain)s/grafana/
Nginx configuration with sub path
HAProxy configuration with sub path
bind *:80
use_backend grafana_backend if { path /grafana } or { path_beg /grafana/ }
# Requires haproxy >= 1.6
http-request set-path %[path,regsub(^/grafana/?,/)]
# Works for haproxy < 1.6
# reqrep ^([^\ ]*\ /)grafana[/]?(.*) \1\2
server grafana localhost:3000
Given:
- subpath
grafana
- Grafana installed on
- pattern:
grafana(/)?(.*)
- check the checkbox
- rewrite url set to
http://localhost:3000/{R:2}
- check the
Append query string
checkbox - check the
Stop processing of subsequent rules
checkboxThis is the rewrite rule that is generated in theweb.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>
</rewrite>
See the for more in-depth instructions.