<p>I'm trying to setup <code>Nginx-ingress controller</code> to manage two paths on the same <code>hostname</code> in bare metal based cluster.</p>
<p>In the <strong>app1</strong> namespace i have below nginx resource:-</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app1-ingress
  namespace: app1
spec:
  ingressClassName: nginx
  rules:
  - host: web.example.com
    http:
      paths:
      - path: /app1
        pathType: Prefix
        backend:
          service:
            name: app1-service
            port:
              number: 80
</code></pre>
<p>And in the <strong>app2</strong> namespace i have below nginx resource:-</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app2-ingress
  namespace: app2
spec:
  ingressClassName: nginx
  rules:
  - host: web.example.com
    http:
      paths:
      - path: /app2
        pathType: Prefix
        backend:
          service:
            name: app2-service
            port:
              number: 80
</code></pre>
<p>My <code>app1-service</code> applied first and it is running fine, now when i applied the second <code>app2-service</code> it shows below warning and not able to access it on browser.</p>
<pre><code>Annotations:       &lt;none&gt;
Events:
  Type     Reason    Age   From                      Message
  ----     ------    ----  ----                      -------
  Warning  Rejected  54s   nginx-ingress-controller  All hosts are taken by other resources
  Warning  Rejected  54s   nginx-ingress-controller  All hosts are taken by other resources
  Warning  Rejected  54s   nginx-ingress-controller  All hosts are taken by other resources
</code></pre>
<p>How do i configure my nginx ingress resource to connect multiple service paths on the same hostname?</p>

user4948798
<p>Default Nginx Ingress controller doesn't support having different <code>Ingress</code> resources with the same hostname. You can have one <code>Ingress</code> resource that contains multiple paths, but in this case all apps should live in one namespace. Like this:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app1-ingress
  namespace: app1
spec:
  ingressClassName: nginx
  rules:
  - host: web.example.com
    http:
      paths:
      - path: /app1
        pathType: Prefix
        backend:
          service:
            name: app1-service
            port:
              number: 80
      - path: /app2
        pathType: Prefix
        backend:
          service:
            name: app2-service
            port:
              number: 80
</code></pre>
<p>Splitting ingresses between namespaces is currently not supported by standard Nginx Ingress controller.</p>
<p>You may however take a look at an alternative implementation of <a href="https://github.com/nginxinc/kubernetes-ingress" rel="nofollow noreferrer">Nginx Ingress</a> by Nginx Inc. They have support for <a href="https://github.com/nginxinc/kubernetes-ingress/tree/main/examples/ingress-resources/mergeable-ingress-types" rel="nofollow noreferrer">Mergeable Ingresses</a>.</p>
