All.
I have the following configuration file:
frontend devopsdb
bind *:8080
acl grafana_path path_beg /grafana/
use_backend back_grafana if grafana_path
backend back_grafana
server grafana-dev 10.152.183.155:80
What I need is that when I access the url (172.21.10.76 is my test VM and where HAProxy is): http://172.21.10.76:8080/grafana/ it is redirected to the grafana POD: 10.152.183.155:80
So far so good, it works.
But as soon as it is redirected, the path /grafana/ disappears from the URL and that's why HAProxy stops redirecting... - http://172.21.10.76:8080/login
Is it possible to keep /grafana/ somehow by HAProxy?
The same will happen with another POD /prometheus/
The problem here is that your backend (grafana) doesn't know anything about the path prefix, so when it generates urls, they will be relative to
/
(so,/login
,/api
, etc).You need to tell grafana that it's hosted at a path other than
/
. You can do this with theroot_url
andserve_from_subpath
configuration settings (documented in "Running Grafana behind a reverse proxy").Running grafana from a compose file, that might look like this:
Alternately, you can configure things in your
grafana.ini
file:From the documentation I didn't think
serve_from_subpath
would be necessary, but without that I end up with a redirect loop.