<p>I am using Istio with Grafana enabled in AKS and want to use a subPath like <code>example.com/metrics/grafana</code>. The provided <a href="https://istio.io/latest/docs/tasks/observability/gateways/" rel="nofollow noreferrer">istio documentation</a> only explains how to use it without a subpath, but a subdomain. But this is not an option here.</p>
<p>According to this <a href="https://grafana.com/tutorials/run-grafana-behind-a-proxy/#1" rel="nofollow noreferrer">grafana tutorial</a> I have to set</p>
<pre><code>domain = example.com
root_url = %(protocol)s://%(domain)s:%(http_port)s/metrics/grafana/
serve_from_sub_path = true
</code></pre>
<p>so I have set them in the <code>IstioOperator</code>:</p>
<pre><code>apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
  profile: default
  values:
    [...]
    grafana:
      # Enable Grafana deployment for analytics and monitoring dashboards
      enabled: true
      env:
        GF_SERVER_ROOT_URL: &quot;%(protocol)s://%(domain)s/metrics/grafana/&quot;
        GF_SERVER_DOMAIN: &quot;example.com&quot;
        GF_SERVER_SERVE_FROM_SUB_PATH: &quot;true&quot;
</code></pre>
<p>Additionally I have set up a <code>VirtualService</code></p>
<pre><code>    - name: grafana-route
      match:
        - uri:
            prefix: /metrics/grafana/
      route:
        - destination:
            host: grafana.istio-system.svc.cluster.local
            port:
              number: 3000
</code></pre>
<p>But when I visit example.com/metrics/grafana I keep getting the message:</p>
<blockquote>
<p>If you’re seeing this Grafana has failed to load its application files</p>
<p>This could be caused by your reverse proxy settings.</p>
<p>If you host grafana under subpath make sure your grafana.ini root_path setting includes subpath</p>
<p>If you have a local dev build make sure you build frontend using: npm run dev, npm run watch, or npm &gt; &gt; run build</p>
<p>Sometimes restarting grafana-server can help</p>
</blockquote>
<p>Anyone knows what the problem might be?</p>

<p><code>serve_from_sub_path</code> must be set to <code>false</code>.</p>
<pre><code>    grafana:
      # Enable Grafana deployment for analytics and monitoring dashboards
      enabled: true
      env:
        GF_SERVER_ROOT_URL: &quot;%(protocol)s://%(domain)s/metrics/grafana/&quot;
        GF_SERVER_DOMAIN: &quot;example.com&quot;
        GF_SERVER_SERVE_FROM_SUB_PATH: &quot;false&quot;
</code></pre>
<p>Furthermore the uri has to be rewritten:</p>
<pre><code>    - name: grafana-route
      match:
        - uri:
            exact: /management/grafana
        - uri:
            prefix: /management/grafana/
      rewrite:
        uri: /
      route:
        - destination:
            host: grafana.istio-system.svc.cluster.local
            port:
              number: 3000
</code></pre>
