Using Traefik with Grafana causes infinite 302 redirects to `/login`

I am new to Grafana and have been trying to implement it into my stack. I use Traefik to act as a reverse proxy and load balancer. I was able to setup a rule in Traefik that will point requests visiting my server with the path being exactly /grafana or beginning with /grafana/. This is similar to what is written for configuring Grafana with HAProxy with a sub path.

When I visit my server at I am redirected to with a 302. This happens 20 times until Chrome terminates the connection for redirecting too many times. I believe that Grafana is functioning properly but may be incorrectly configured of the reverse proxy and/or Traefik is passing the request to Grafana in a way that confuses Grafana.

I set my Grafana server root URL to /grafana and Traefik has the Grafana service using the following configuration:

  - 'traefik.enable=true'
  - 'traefik.http.routers.grafana.rule=Path(`/grafana`) || PathPrefix(`/grafana/`)'
  - 'traefik.http.routers.grafana.entrypoints=web'
  - 'traefik.http.middlewares.grafana-compress.compress=true'
  - ''

What value for the root_url do you have in your grafana.ini?

I have set the GF_SERVER_ROOT_URL environment variable to and the GF_SERVER_DOMAIN environment variable to

Okay, super! Let me see if I can reproduce this one. Will get back to you.

1 Like

I just realized that you might not do a url rewrite. Please try to add this env to your grafana instance:


as specified here:

1 Like