I am trying to host static files in kubernetes with an nginx container, and expose them on a private network with istio.
I want the root of my server to exist at site.com/foo, as I have other applications existing at site.com/bar, site.com/boo, etc.
My istio virtual service configuration:
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: cluster-foo
  namespace: namespace
spec:
  gateways:
  - cluster-gateway
  hosts:
  - site.com
  http:
  - match:
    - name: http
      port: 80
      uri:
        prefix: /foo
    route:
    - destination:
        host: app.namespace.svc.cluster.local
        port:
          number: 80
All of my static files exist in the directory /data on my nginx container. My nginx config:
events {}
http {
    server {
        root /data;
        location /foo {
            autoindex on;
        }
    }
}
Applying this virtual service, and a kube deployment that runs an nginx container with this config, I get a nginx server at site.com/foo that serves all of the static files in /data on the container. All good. The problem is that the autoindexing that nginx does, does not respect the prefix /foo. So all the file links that nginx indexes at site.com/foo, look like this:
site.com/page.html, rather than site.com/foo/page.html. Furthermore, when I put site.com/foo/page.html in my browser manually, site.com/foo/page.html is displayed correctly, So I know that nginx is serving it in the correct location, just the links that it is indexing are incorrect.
Is there any way to configure nginx autoindex with a prefix?
 
    