<p>Following this <a href="https://kubernetes.github.io/ingress-nginx/deploy/#using-helm" rel="nofollow noreferrer">guide</a>, I created an ingress controller on my local kubernetes server, the only difference is that it is created as a NodePort.</p>
<p>I have done some test deployments, with respective services and everything works, here the file</p>
<p>Deploy1:</p>
<pre><code>apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: helloworld1
spec:
  selector:
    matchLabels:
      app: helloworld1
  replicas: 1
  template:
    metadata:
      labels:
        app: helloworld1
    spec:
      containers:
      - name: hello
        image: gcr.io/google-samples/hello-app:1.0
        ports:
        - containerPort: 8080
</code></pre>
<p>Deploy2:</p>
<pre><code>apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: helloworld2
spec:
  selector:
    matchLabels:
      app: helloworld2
  replicas: 1
  template:
    metadata:
      labels:
        app: helloworld2
    spec:
      containers:
      - name: hello
        image: gcr.io/google-samples/hello-app:2.0
        ports:
        - containerPort: 8080
</code></pre>
<p>Deploy3:</p>
<pre><code>apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: geojson-example
spec:
  selector:
    matchLabels:
      app: geojson-example
  replicas: 1
  template:
    metadata:
      labels:
        app: geojson-example
    spec:
      containers:
        - name: geojson-container
          image: &quot;nmex87/geojsonexample:latest&quot;
          ports:
            - containerPort: 8080
</code></pre>
<p>Service1:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: helloworld1
spec:
#  type: NodePort
  ports:
  - port: 8080
  selector:
    app: helloworld1
</code></pre>
<p>Service2:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: helloworld2
spec:
#  type: NodePort
  ports:
  - port: 8080
  selector:
    app: helloworld2
</code></pre>
<p>Service3:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: geojson-example
spec:
  ports:
    - port: 8080
  selector:
    app: geojson-example
</code></pre>
<p>This is the ingress controller:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/default-backend: geojson-example
spec:
  rules:
    - http:
        paths:
          - path: /geo
            pathType: Prefix
            backend:
              service:
                name: geojson-example
                port:
                  number: 8080
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080
</code></pre>
<p>When I do a GET on <strong>myServer:myPort/test1</strong> or <strong>/test2</strong> everything works, on <strong>/geo</strong> i get the following answer</p>
<pre><code>{
    &quot;timestamp&quot;: &quot;2021-03-09T17:02:36.606+00:00&quot;,
    &quot;status&quot;: 404,
    &quot;error&quot;: &quot;Not Found&quot;,
    &quot;message&quot;: &quot;&quot;,
    &quot;path&quot;: &quot;/geo&quot;
}
</code></pre>
<p>Why??
if I create a pod, and from inside the pod, i do a curl on <strong>geojson-example</strong> it works, but from the external, i obtain a 404 (i think by nginx ingress controller)</p>
<p>This is the log of nginx pod:</p>
<pre><code>x.x.x.x - - [09/Mar/2021:17:02:21 +0000] &quot;GET /test1 HTTP/1.1&quot; 200 68 &quot;-&quot; &quot;PostmanRuntime/7.26.8&quot; 234 0.006 [default-helloworld1-8080] [] 192.168.168.92:8080 68 0.008 200 

x.x.x.x - - [09/Mar/2021:17:02:36 +0000] &quot;GET /geo HTTP/1.1&quot; 404 116 &quot;-&quot; &quot;PostmanRuntime/7.26.8&quot; 232 0.013 [default-geojson-example-8080] [] 192.168.168.109:8080 116 0.012 404 
</code></pre>
<p>What can I do?</p>

<p>As far the doc: This annotation is of the form <code>nginx.ingress.kubernetes.io/default-backend: &lt;svc name&gt;</code> to specify a custom default backend. This <code>&lt;svc name&gt;</code> is a reference to a service inside of the same namespace in which you are applying this annotation. This annotation overrides the global default backend.</p>
<p>This service will be handle the response when the service in the Ingress rule does not have active endpoints.</p>
<p>You cannot use same service as default backend and also for a path. When you do this the path <code>/geo</code> became invalid. As we know default backend serves only the inactive endpoints. Now If you tell that you want <code>geojson-example</code> as default backend(for inactive endpoints) again in the paths if you tell that use <code>geojson-example</code> for a valid path <code>/geo</code> then it became invalid as you are creating a deadlock type situation here.</p>
<p>You actually do not need to give this <code>nginx.ingress.kubernetes.io/default-backend</code> annotation.</p>
<p>Your ingress should be like below without the default annotation, or you can use the annotation but in that case you need to remove <code>geojson-example</code> from using for any valid path in the paths, or need to use another service for the path <code>/geo</code>. Options that you can use are given below:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
  rules:
    - http:
        paths:
          - path: /geo
            pathType: Prefix
            backend:
              service:
                name: geojson-example
                port:
                  number: 8080
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080
</code></pre>
<p>Or:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/default-backend: geojson-example
spec:
  rules:
    - http:
        paths:
          - path: /geo
            pathType: Prefix
            backend:
              service:
                name: &lt;any_other_service&gt;    # here use another service except `geojson-example`
                port:
                  number: 8080
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080
</code></pre>
<p>Or:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    nginx.ingress.kubernetes.io/default-backend: geojson-example
spec:
  rules:
    - http:
        paths:
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080
</code></pre>
