<p>I have my dashboards exposed to <code>&lt;dashboard&gt;.foobar.com</code> with no problem, now I am trying to expose dashboards mentioned above to <code>www.foobar.com/dashboard/&lt;kiali&gt;</code>
I have tested with a simple .net backend container with this VS set up:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: whatever
spec:
  hosts:
  - www.foobar.com
  gateways:
  - some-gateway
  http:
  - match:
    - uri:
        prefix: /bla
    rewrite:
      uri: &quot; &quot;
    route:
    - destination:
        port:
          number: 1234
        host: dummy-service
</code></pre>
<p>Then I have:
<code>foobar.com/bla/api/hello</code> -&gt; <code>dummyservice/api/hello</code>
<code>foobar.com/bla/api/deeper/hello</code> -&gt; <code>dummyservice/api/deeper/hello</code>
which is good.
However, if I apply the same to those dashboards, nothing works!
Here is my setting for the dashboards:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: dashboards
  namespace: istio-system
spec:
  hosts:
  - www.foobar.com
  gateways:
  - default/somegateway
  http:
  - name: grafana
    match:
    - uri:
        prefix: /dashboards/grafana
    rewrite:
      uri: /
    route:
    - destination:
        port:
          number: 80
        host: grafana.grafana.svc.cluster.local
  - name: prometheus
    match:
    - uri:
        prefix: /dashboards/prometheus
    rewrite:
      uri: &quot;/&quot;
    route:
    - destination:
        port:
          number: 9089
        host: prometheus-server.prometheus.svc.cluster.local
  - name: kubernetes-dashboard
    match:
    - uri:
        prefix: &quot;/dashboards/kubernetes&quot;
    rewrite:
      uri: &quot; &quot;
    route:
    - destination:
        port:
          number: 8443
        host: kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local
  - name: kubernetes-dashboard
    match:
    - uri:
        prefix: &quot;/dashboards/kiali/&quot;
    rewrite:
      uri: /
    route:
    - destination:
        port:
          number: 20001
        host: kiali.istio-system.svc.cluster.local
</code></pre>
<p>As someone mentioned there is a known issue with <code>/</code> and <code> </code> so you can see I have <code>rewrite</code> for both of them. But still nothing works.
I got 404 for most of them, and grafana redirects me to <code>www.foobar.com/login</code></p>
<p>Anyone have done this before? I am thinking of maybe these dashboards are frontend included, so its not that simple as my .net backend container?</p>

<p>For anyone has the same question, please take a look here:</p>
<p>I have this resolved:</p>
<p>So first, the VirtualSerive are correct, but remember to add quotes to write section:</p>
<pre><code>    rewrite:
      uri: &quot;/&quot;
</code></pre>
<p>And prefix sections need to be closed with a <code>/</code></p>
<pre><code>  - name: kubernetes-dashboard
    match:
    - uri:
        prefix: &quot;/kubernetes/&quot;
</code></pre>
<p>Here comes the trick, prometheus and grafana are designed to be worked at root url. However, its configurable in the <code>deployment.yaml</code>
For example, I want my grafana and prometheus works at <code>www.foobar.com/grafana/</code> and <code>www.foobar.com/prometheus</code> respectively.
In grafana <code>deployment.yaml</code>, we need to specify:</p>
<pre><code>          env:
            - name: GF_SERVER_ROOT_URL
              value: 'http://localhost:3000/grafana/'
            - name: GF_SERVER_DOMAIN
              value: localhost
            - name: GF_SERVER_SERVE_FROM_SUB_PATH
              value: 'true'
</code></pre>
<p>And in prometheus, it has the similar:</p>
<pre><code>- name: prometheus-server
    image: 'quay.io/prometheus/prometheus:v2.24.0'
    args:
      - '--web.enable-lifecycle'
      - '--web.external-url=https://localhost:9090/prometheus/'
      - '--web.route-prefix=/'
</code></pre>
<p>For kiali, the trick is in virtual service, you have to rewrite it to <code>/kiali/</code>:</p>
<pre><code>  - name: kiali-dashboard
    match:
    - uri:
        prefix: /kiali/
    rewrite:
      uri: &quot;/kiali/&quot;
</code></pre>
