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.

    1. [server]
    2. domain = foo.bar

    Grafana configuration with sub path

    1. [server]
    2. domain = foo.bar
    3. root_url = %(protocol)s://%(domain)s/grafana/

    Nginx configuration with sub path

    HAProxy configuration with sub path

    1. bind *:80
    2. use_backend grafana_backend if { path /grafana } or { path_beg /grafana/ }
    3. # Requires haproxy >= 1.6
    4. http-request set-path %[path,regsub(^/grafana/?,/)]
    5. # Works for haproxy < 1.6
    6. # reqrep ^([^\ ]*\ /)grafana[/]?(.*) \1\2
    7. 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 the web.config:
    1. <rewrite>
    2. <rules>
    3. <rule name="Grafana" enabled="true" stopProcessing="true">
    4. <match url="grafana(/)?(.*)" />
    5. <action type="Rewrite" url="http://localhost:3000/{R:2}" logRewrittenUrl="false" />
    6. </rule>
    7. </rewrite>

    See the for more in-depth instructions.