Problem with reaching grafana frontend with url including orgId


I have three grafanas deployed in docker containers and assigned to one domain in my network. I have also haproxy as a load balancer, which connecting user with choosen by its grafana instance, and I’m using keycloak for authentication.

fragment of my haproxy configuration:

# grafana http
frontend grafana
    mode http
    default_backend grafana_bk

backend grafana_bk
    reqrep ^([^\ :])\ <<grafana_base_uri>>/(.) \1\ /\2
    balance roundrobin
# grafana checks if Host header is present if HTTP 1.1 is used
    option httpchk GET /login HTTP/1.0
    cookie grafana_sess prefix nocache

And fragment of my grafana configuration:

# Protocol (http or https)
protocol = http

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port  to use
http_port = <<grafana_port>>

# The public facing domain name used to access grafana from a browser
domain = <<grafana_domain>>

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
;enforce_domain = false

# The full public facing url
root_url = %(protocol)s://%(domain)s/<<grafana_base_uri>>

The problem is:
When I try to reach grafana with standard url http://<<grafana_domain>>/<<grafana_base_uri>>/d/<<dashboard_id>>/<<dashboard_name>>
I can reach grafana site and display my dashboard, but when I’m trying reach grafana with link with specified other organisation ID:
Connection last very long time and I’m reaching ERR_EMPTY_RESPONSE
But I can reach that other dashboard linked to other organisation, when I will click it in grafana frontend by switching organisation and choosing that dashboard.

What can I change in configuration to make grafana reachable with all possible URLs?
I’ve tried changing many parameters in haproxy and grafana and I didn’t resolve that problem.


Really nobody can help me?

Grafana provides an api endpoint for switching orgs programatically but I think you cannot send an additional request with HAProxy. Maybe with nginx or custom node/python app?