title: K8s Ingress rule for multiple paths in same backend service
body: <p>I am trying to setup ingress load balancer.
  Basically, I have a single backend service with multiple paths.</p>
  <p>Let's say my backend NodePort service name is hello-app. The pod associated with this service exposes multiple paths like /foo and /bar. Below is the example</p>
  <p>NodePort service and associated deployment</p>
  <pre class="lang-yaml prettyprint-override"><code>    apiVersion: v1
      kind: Service
      metadata:
        name: hello-app
      spec:
        selector:
          app: hello-app
        type: NodePort
        ports:
          - protocol: &quot;TCP&quot;
            port: 7799
            targetPort: 7799
      ---
      apiVersion: apps/v1 
      kind: Deployment
      metadata:
        name: hello-app
        labels:
          app: hello-app
      spec:
        replicas: 1
        selector:
          matchLabels:
            app: hello-app
        template:
          metadata:
            labels:
              app: hello-app
          spec:
            containers:
            - name: hello-app
              image: us.gcr.io/hello-app:latest
  </code></pre>
  <p>Now onn making request like below I am facing 404 error.</p>
  <pre><code>http://{ingress-address:port}/foo
  http://{ingress-address:port}/bar
  </code></pre>
  <p>I have tried below ingress configurations alternatively, but in both cases it didn't helped.</p>
  <p><strong>Ingress configuration 1</strong></p>
  <pre class="lang-yaml prettyprint-override"><code>    apiVersion: extensions/v1beta1
      kind: Ingress
      metadata:
        name: basic-ingress
      spec:
        rules:
        - http:
            paths:
            - path: /*
              backend:
                serviceName: hello-app
                servicePort: 7799
  </code></pre>
  <p><strong>Ingress configuration 2</strong></p>
  <pre class="lang-yaml prettyprint-override"><code>    apiVersion: extensions/v1beta1
      kind: Ingress
      metadata:
        name: basic-ingress
      spec:
        backend:
          serviceName: hello-app
          servicePort: 7799
  </code></pre>
  <p><strong>Error Message</strong></p>
  <p>10.88.16.10 - - [20/Jan/2019 08:50:55] &quot;GET / HTTP/1.1&quot; 404 -
  [2019-01-20 08:50:55] [INFO] [_internal] [_log] 10.88.16.10 - - [20/Jan/2019 08:50:55] &quot;GET / HTTP/1.1&quot; 404 -</p>
  <p>I have looked into example mention in <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer" rel="nofollow noreferrer">this</a> link, but it assumes that different path refers to different backend service. In my case, multiple paths belong to the same backend service.</p>
  <p>It looks like the full path is not being forwarded to downstream backend service from ingress which is resulting into the invalid request.
  Can somebody please suggest what is the correct way to configure ingress for the above requirement?</p>