Configure reverse proxy via Spring Cloud Gateway

  • What Grafana version and what operating system are you using?
    Grafana version: 8.3.4
    OS: Windows 10

  • What are you trying to achieve?
    I am trying to configure reverse proxy for Grafana using Spring Cloud Gateway.

  • How are you trying to achieve it?
    I have read through the Run Grafana through a reverse proxy article on the Grafana docs and updated my custom.ini file with the following:

root_url =

serve_from_sub_path = true

I have also added the following static route in my Spring Cloud Gateway application.yml file:

        # Static routes
        routes:
        
        # Redirect to Grafana
        -   id: grafana
            uri: http://localhost:3000
            predicates:
            -   Path=/grafana**
            filters:
            - RewritePath=/grafana/(?<remaining>.+), /$\{remaining}
  • What happened?
    When accessing Grafana through the reverse proxy URL the login page for Grafana successfully loads however when entering my login details for grafana a message appears on screen “Invalid CSRF Token” and I get a 403 Forbidden response. I tried accessing Grafana without the reverse proxy enabled through localhost:3000 with the same credentials and was able to login successfully.

  • What did you expect to happen?
    I expected to be able to login into Grafana via the reverse proxy. Is there something in the Grafana configuration I am missing that may solve this?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    In the Grafana logs I can see this message. I’m not sure if it indicates the problem:

“Validated license token” logger=licensing appURL=http://localhost:8080/grafana/ source=disk status=NotFound

This is the grafana configuration used. Not sure what happened when I made the post:

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
root_url = http://localhost:8080/grafana

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
serve_from_sub_path = true