<p>I have a K8s cluster with multiple different services deployed and would like to use a single <code>Ingress</code> to route each incoming request to the appropriate service via a unique hostname <code>DNS</code>.</p>
<p>Currently, I've only been able to resolve a request when using the root path i.e. <code>service-123.app.com</code>.</p>
<p>As soon as I try to make a request with a path it doesn't resolve. The paths are valid paths to each service. For example, <code>service-123.app.com/page/12345</code> would be expected by the application.</p>
<p>I might not fully understand how K8s Ingress rules are expected to work, but I hoped that it would match based on hostname only and simply forward on the path to the appropriate service.</p>
<p>Am I missing something very simple here? Any help is much appreciated. Thanks!</p>
<p>Here are my config files.</p>
<p><strong>Ingress.yaml</strong></p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ......
  name: app-name
  namespace: default
spec:
  rules:
  - host: service-123.app.com
    http:
      - path: &quot;/*&quot;
        backend:
          serviceName: service-123
          servicePort: 80
  - host: service-456.app.com
    http:
      paths:
      - path: &quot;/*&quot;
        backend:
          serviceName: service-456
          servicePort: 80
</code></pre>
<p><strong>service.yaml</strong></p>
<pre><code>---
apiVersion: v1
kind: Service
metadata:
  annotations: {}
  labels:
    app: service-123
  name: service-123
  namespace: default
spec:
  ports:
  - name: port8080
    port: 80
    targetPort: 8080
  selector:
    app: service-123
  type: NodePort
</code></pre>

user2252867
<p>Not sure which K8s and ingress controller you are using, but in the later K8s you can specify the <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types" rel="nofollow noreferrer"><code>pathType</code></a> which takes care of path wildcards more nicely.</p>
<p>You would have something like this:</p>
<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ......
  name: app-name
  namespace: default
spec:
  rules:
  - host: service-123.app.com
    http:
      - path: /
        pathType: Prefix
        backend:
          serviceName: service-123
          servicePort: 80
  - host: service-456.app.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          serviceName: service-456
          servicePort: 80
</code></pre>
<p>If you are using an <a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">nginx ingress controller</a> a good way to see the right nginx configuration is by looking at the actual <code>nginx.conf</code> generated by the ingress controller.</p>
<pre><code>$ kubectl cp &lt;nginx-ingress-controller-pod&gt;:nginx.conf nginx.conf
$ cat nginx.conf
</code></pre>
