<p>I have set up a kubernetes cluster on Azure with nginx ingress. I am getting a 404 error when navigating to a particular path.</p>

<p>I have set up some sample applications that return a simple echo that works perfectly fine. My ban api app always returns a 404 error. </p>

<p>When I navigate to the ingress path e.g. </p>

<pre><code>http://51.145.17.105/apple
</code></pre>

<p>It works fine. However when I navigate to the api application, I get a 404 error using the URL:</p>

<pre><code>http://51.145.17.105/ban-simple
</code></pre>

<p>If I log into the cluster and curl the ban-simple service (not the ingress ip) e.g. </p>

<pre><code>curl -L 10.1.1.40
</code></pre>

<p>I get the correct response. When I try it using the nginx ingress I get the 404 error.</p>

<p>The ingress mapping looks right to me. Here is a copy of the ingress yaml containing the paths.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fruit-ingress
  namespace: ban
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /$
spec:
  rules:
  - http:
      paths:
        - path: /apple
          backend:
            serviceName: apple-service
            servicePort: 5678
        - path: /ban-simple
          backend:
            serviceName: ban-service
            servicePort: 80
</code></pre>

<p>A copy of the "good" service is:</p>

<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: apple-app
  namespace: ban
  labels:
    app: apple
spec:
  containers:
    - name: apple-app
      image: hashicorp/http-echo
      args:
        - "-text=apple"

---

kind: Service
apiVersion: v1
metadata:
  name: apple-service
  namespace: ban
spec:
  selector:
    app: apple
  ports:
    - port: 5678 # Default port for image
</code></pre>

<p>The service that does not work is:</p>

<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: ban-simple
  namespace: ban
  labels:
    app: ban-simple
spec:
  containers:
    - name: ban-simple
      image: xxxxx.azurecr.io/services/ban

---

kind: Service
apiVersion: v1
metadata:
  name: ban-simple-service
  namespace: ban
spec:
  selector:
    app: ban-simple
  ports:
    - port: 80 # Default port for image
</code></pre>

<p>I have run the container locally and it works on my machine. It does redirect to localhost/index.html if that makes a difference.</p>

<p>Any suggestions are appreciated.</p>

IHelpPeople
<p>It was <code>nginx.ingress.kubernetes.io/rewrite-target: /$</code>  that was causing the issue. I commented it out and it resolved the issue.</p>
