<p>I'm a beginner with K8s, and I'm testing multiple scenarios, so I've got the next problem:</p>
<p><strong>When I apply an Ingress with 2 paths, the server response 404 for every URI</strong></p>
<p>This is my ingress YAML file</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress
  namespace: pruebas
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: parking.io
    http:
      paths:
      - backend:
          serviceName: front
          servicePort: 80
        path: /front
      - backend:
          serviceName: back
          servicePort: 80
        path: /api
</code></pre>
<p>I've done several tests and these were the results:</p>
<ul>
<li>Only 1 path with &quot;/&quot; for &quot;front&quot;: Works ✅</li>
<li>Only 1 path with &quot;/&quot; for &quot;back&quot;: Works ✅</li>
<li>Only 1 path for &quot;front&quot; with &quot;/front&quot;: Not works ❌</li>
<li>Only 1 path for &quot;front&quot; with &quot;/backend&quot;: Not works ❌</li>
<li>2 paths for &quot;front&quot; and &quot;back&quot; (the YAML file above) : Not works ❌</li>
</ul>
<p>Api Service YAML:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: back
  namespace: pruebas
spec:
  type: ClusterIP
  selector:
    type: backend
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
</code></pre>
<p><strong>Additional info:</strong> I made a test creating 2 services for hello-world of Nginx, I made the same that I said before and It works fine, So, I'm guessing I have a problem with my services or my pods, but I don't know what it could be.</p>
<p><strong>More additional info</strong> It's running on GCP with GKE.</p>
<p><strong>Updated</strong> I put this (<em>nginx.org/rewrites: &quot;serviceName=back rewrite=/&quot;</em>) and the route for API works, but not for the child routes (api/whatever)</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress
  namespace: pruebas
  annotations:
    # nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.org/rewrites: &quot;serviceName=back rewrite=/&quot;
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: parking.io
    http:
      paths:
      # - backend:
      #     serviceName: front
      #     servicePort: 80
      #   path: /app
      - backend:
          serviceName: nginx-2
          servicePort: 80
        path: /hello
      - backend:
          serviceName: back
          servicePort: 80
        path: /api
</code></pre>
<p>All the info inside my namespace &quot;pruebas&quot;:</p>
<p><a href="https://i.stack.imgur.com/JJwZp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JJwZp.png" alt="enter image description here" /></a></p>

Andres Ruales
<p>I resolve my problem by making these changes:</p>
<ul>
<li>Uninstall my ingress controller, and then remove the services, pods, and all related to it.</li>
<li>I had my ingress controller on a different namespace (infra), So, I installed again the NGINX ingress controller in the same namespace of my services and pods (pruebas)</li>
<li>I configured my ingress in the same namespace as the other pods, services, etc.</li>
</ul>
<p>My cluster was configured on GKE, So, I don't know if this solution applies to different services.</p>
