Page Not Found Error on Garfana UI v11.2 when using reverse-proxy

Hi,

I am trying to serve Grafana via nginx reverse-proxy. The domain has a root url and then we serve it via grafana service -
https://domainname.com/k8s/v4/{slug}/clusters/{cluster_id}/k8sapi/api/v1/namespaces/pf9-monitoring/services/http:grafana-ui:80/proxy/login

I am able to serve the Grafana UI via the proxy url but the UI shows “Page Not Found”.
I suspect this is due to the reac-router used in Grafana UI which is not able to get matching pathname and fallback to the 404-Page not found

I tried add root_url given above to the grafana config -

root_url = https://domainname.com/k8s/v4/{cluster_id}/clusters/{cluster_id}/k8sapi/api/v1/namespaces/pf9-monitoring/services/http:grafana-ui:80/proxy/login

serve_from_sub_path = false

But it gives the below error after doing so -

My nginx config looks like this -

apiVersion: v1
data:
  default.conf: |
    server {
        listen 80;

        location / {
            proxy_pass http://localhost:3000;  # Proxy to the Grafana container
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }

I can see that the Grafana receives the config via window.grafanaBootData.settings which contains appSubUrl and appUrl. And the routing works properly when we setup appSubUrl

When we setup root_url, both appSubUrl and appUrl are configure and this doesn’t work in my case. Is there a way we can setup the appSubUrl only via grafana config ?

try a rewrite rule:
rewrite ^/grafana/(.*) /$1 break;

@sowdenraymond We are not serving grafana behind any subpath. Is the rewrite necessary in that case ?

i have a couple of instances configured behind npm, which is basically like nginx with a gui, and i have to do the rewrite or i get the dreaded orange message about not being able to find its files.

Hi,

I think better create ingress and pointing the ingress to that service in kubernetes, then you just point the proxy_pass to that endpoint.
I use this approach to all my grafana that contain in Kubernetes cluster, easy enough to set in the nginx reverse proxy.

Regards,
Fadjar