<p>currently I'm trying the following setup:</p>
<p>I have:</p>
<ul>
<li>one cluster</li>
<li>one Ingress Controller</li>
<li>one url (myapp.onazure.com)</li>
<li>two namespaces for two applications default and default-test</li>
<li>two deployments, ingress objects, services for the namespaces</li>
</ul>
<p>I can easily reach my app from the default namespace with path based routing '/' as a prefix rule
Now i have tried to configure the second namespace and following rule: /testing to hit another service</p>
<p>Unfortunately i get an HTTP404 when i try to hit the following URL myapp.onazure.com/testing/openapi.json</p>
<p>What did I miss?</p>
<p><strong>Working Ingress 1</strong></p>
<pre><code>kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
  name: liveapi-ingress-object
  namespace: default
  annotations:
    kubernetes.io/ingress.class: public-nginx
spec:
  tls:
    - hosts:
        - myapp-region1.onazure.com
        - myapp-region2.onazure.com
      secretName: ingress-tls-csi
  rules:
    - host: - myapp-region1.onazure.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: liveapi-svc
                port:
                  number: 8080
    - host: myapp-region2.onazure.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: liveapi-svc
                port:
                  number: 8080

</code></pre>
<p><strong>Not working Ingress 2</strong></p>
<pre><code>kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
  name: liveapi-ingress-object-testing
  namespace: default-testing
  annotations:
    kubernetes.io/ingress.class: public-nginx
    #nginx.ingress.kubernetes.io/rewrite-target: /testing
spec:
  tls:
    - hosts:
        - myapp-region1.onazure.com
        - myapp-region2.onazure.com
      secretName: ingress-tls-csi-testing
  rules:
    - host: myapp-region1.onazure.com
      http:
        paths:
          - path: /testing
            #pathType: Prefix
            backend:
              service:
                name: liveapi-svc-testing
                port:
                  number: 8080
    - host: myapp-region2.onazure.com
      http:
        paths:
          - path: /testing
            #pathType: Prefix
            backend:
              service:
                name: liveapi-svc-testing
                port:
                  number: 8080


</code></pre>
<p>Maybe I am missing a rewrite target to simply '/' in the testing namespace ingress?</p>

Artur123
<p>Finally I figured out the missing part. I had to add the following statement to the not working ingress object:</p>
<pre><code>  annotations:
    kubernetes.io/ingress.class: public-nginx
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$1
</code></pre>
<p>Please see the complete ingress object:</p>
<pre><code>kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
  name: liveapi-ingress-object
  namespace: default-testing
  annotations:
    kubernetes.io/ingress.class: public-nginx
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  tls:
    - hosts:
        - myapp.onazure.com
      secretName: ingress-tls-csi-testing
  rules:
    - host: myapp.onazure.com
      http:
        paths:
          - path: /testing/(.*)
            pathType: Prefix
            backend:
              service:
                name: liveapi-svc-testing
                port:
                  number: 8000 

 
</code></pre>
