<p>I have this ingress and service created on my Kubernetes cluster</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
metadata:
  name: google-storage-buckets
spec:
  type: ExternalName
  externalName: storage.googleapis.com
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: proxy-assets-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /kinto-static-websites/gatsby/public/$1
    nginx.ingress.kubernetes.io/upstream-vhost: &quot;storage.googleapis.com&quot;
    nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
spec:
  rules:
  - host: gatsby.vegeta.kintohub.net
    http:
      paths:
      - path: /(.*)$
        backend:
          serviceName: google-storage-buckets
          servicePort: 443
</code></pre>
<p>However, this works only if I add <code>index.html</code> after gatsby.vegeta.kintohub.net.</p>
<p>Same if I go on gatsby.vegeta.kintohub.net/page-2.</p>
<p>How could I make this work plz?</p>
<p>Thanks</p>

bappr
<p>We had a very similar case, gatsby static site on a GCP bucket.</p>
<p>we also tested <code>try_files</code> and <code>index</code> directives but didn't work.</p>
<p>In our case these hacky <code>configuration-snippets</code> did the trick:</p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: gcp-storage-bucket
spec:
  type: ExternalName
  externalName: storage.googleapis.com

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /&lt;BUCKET_NAME&gt;$uri
    nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
    nginx.ingress.kubernetes.io/upstream-vhost: &quot;storage.googleapis.com&quot;
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ($uri ~ &quot;^/(.*)/$&quot;) {
        rewrite ^(.+)/$ $1 last;
        proxy_pass  https://storage.googleapis.com;
      }
      if ($uri ~ &quot;^\/$&quot;) {
        rewrite ^ /&lt;BUCKET_NAME&gt;/index.html break;
        proxy_pass  https://storage.googleapis.com;
      }
      if ($uri !~ &quot;^(.*)\.(.*)$&quot;) {
        rewrite ^ /&lt;BUCKET_NAME&gt;$uri/index.html break;
        proxy_pass  https://storage.googleapis.com;
      }
  labels:
    app.kubernetes.io/instance: static-site.example.com
  name: static-site.example.com
  namespace: default
spec:
  rules:
  - host: static-site.example.com
    http:
      paths:
      - path: /(.*)
        backend:
          service:
            name: gcp-storage-bucket
            port:
              number: 443
        pathType: Prefix
</code></pre>
<p>Everything seems to be working fine on our case, except for the 404s</p>
<p>There might be a more efficient way to do this but hopes this helps.</p>
