Grafana behind reverse proxy (nginx) with subpath

Thanks, but this unfortunately does not help me. The intended issue behind the question is that I’d like to redirect things like example.com/foo/grafana and example.com/bar/grafana to separate Grafana instances using reverse proxy. So if there is no civilized way to do the redirect, I need to think of a different solution.

And where is a problem?

nginx:

  location /foo/grafana {
    proxy_set_header Host $host;
    proxy_pass http://foo-grafana:80/foo/grafana/;
  }

  location /bar/grafana {
    proxy_set_header Host $host;
    proxy_pass http://bar-grafana:80/bar/grafana/;
  }

foo grafana:

[server]
http_port = 80
domain = localhost
root_url = %(protocol)s://%(domain)s:%(http_port)s/foo/grafana/
serve_from_sub_path = true

bar grafana:

[server]
http_port = 80
domain = localhost
root_url = %(protocol)s://%(domain)s:%(http_port)s/bar/grafana/
serve_from_sub_path = true

Of course some testing and minor polishing may be needed - these are not copy&paste, 100% valid configs.

1 Like

Yeah, thanks, I’ll likely end up with something like this.