<p>I'm trying to set up a kubernetes cluster in GKE using nginx-ingress to handle request routing.  I have two different projects which I would like to host within the same domain, with each managing their own ingress definition.  The readme <a href="https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/ingress-path-matching.md#path-priority" rel="nofollow noreferrer">here</a> seems to show something similar, so I assume this should be possible.</p>

<p>When I deploy either ingress individually, everything works great and I can access the routes I would expect.  However, when I add both at the same time, only the ingress with the metadata.name value that comes first alphabetically will reach the intended backend, while the other ingress will return a 404 from nginx-ingress.</p>

<p>If I switch the metadata.name values, this behavior is consistent (the ingress that has the first alphabetical name will work), so I don't think it has to do with the routes themselves or the services / pods involved but rather something to do with how nginx-ingress is handling the ingress names.</p>

<p>I've tried various versions of the nginx-ingress-controller:</p>

<ul>
<li>quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.24.1</li>
<li>quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.24.0</li>
<li>quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.23.0</li>
<li>quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.22.0</li>
</ul>

<p>I've also tried forcing regex route matching (using <code>nginx.ingress.kubernetes.io/rewrite-target: /</code>), swapping the names on the ingress, deploying the projects to different namespaces, and changing the paths to be entirely distinct with no luck - only one ingress file will be used at a time.</p>

<p>Finally, I tried making one ingress file with both definitions in it (so there's only one ingress name in play), and that works fine.  Comparing the nginx configuration of the unified, working setup with a non-working one, the only line that is different is the "set $ingress_name", e.g.:</p>

<pre><code>set $ingress_name   "test-ingress-1";
</code></pre>

<p>vs</p>

<pre><code>set $ingress_name   "test-unified-ingress";
</code></pre>

<p>Here are the ingresses (with the hostname changed):</p>

<p>test-ingress-1.yaml:</p>

<pre><code>apiVersion: extensions/v1beta1                               
kind: Ingress                                                
metadata:                                                    
  annotations:                                               
    kubernetes.io/ingress.class: nginx                 
    nginx.ingress.kubernetes.io/from-to-www-redirect: "false"                          
  name: test-ingress-1                                       
  namespace: default                                         
spec:                                                        
  rules:                                                     
  - host: test.com                               
    http:                                                    
      paths:                                                 
      - backend:                                             
          serviceName: test-frontend                         
          servicePort: 80                                    
        path: /test                    
status:                                                      
  loadBalancer: {}                                           
</code></pre>

<p>test-ingress-2.yaml:</p>

<pre><code>apiVersion: extensions/v1beta1                               
kind: Ingress                                                
metadata:                                                    
  annotations:                                               
    kubernetes.io/ingress.class: nginx                 
    nginx.ingress.kubernetes.io/from-to-www-redirect: "false"                          
  name: test-ingress-2                                       
  namespace: default                                         
spec:                                                        
  rules:                                                     
  - host: test.com                               
    http:                                                    
      paths:                                                 
      - backend:                                             
          serviceName: test-backend                         
          servicePort: 80                                    
        path: /api/test                    
status:                                                      
  loadBalancer: {} 
</code></pre>

<p>I would expect those two separate ingress files to configure nginx together, but haven't had success.  Is there something that I'm missing or doing wrong?</p>

<p>Thank you for any assistance!</p>

<p>Why you just don't put multiple paths into one ingress file? </p>

<pre><code>apiVersion: extensions/v1beta1                               
kind: Ingress                                                
metadata:                                                    
  annotations:                                               
    kubernetes.io/ingress.class: nginx                 
    nginx.ingress.kubernetes.io/from-to-www-redirect: "false"                          
  name: test-ingress-1                                       
  namespace: default                                         
spec:                                                        
  rules:                                                     
  - host: test.com                               
    http:                                                    
      paths:
      - path: /test                                                 
        backend:                                             
          serviceName: test-frontend                         
          servicePort: 80                                    
      - path: /api/test
        backend:                                             
          serviceName: test-backend                         
          servicePort: 80                                    
status:                                                      
  loadBalancer: {}  
</code></pre>

<p>Or use <code>rewrite-target</code>  as suggested below</p>
