<p>I have a Kubernetes cluster with two applications which provide web-frontends, and I would like to make both of them accesible through an NGINX ingress controller. This is the relevant part of my ingress.yaml:</p>

<pre><code>tls:
  - hosts:
    - myapp.com
    secretName: my-certificate
  rules:
  - host: myapp.com
    http:
      paths:
      - backend:
          serviceName: myapp2-service
          servicePort: 12345
        path: /myapp2/(.*)
      - backend:
          serviceName: myapp1-service
          servicePort: 80
        path: /(.*)
</code></pre>

<p>With this setup, I can reach the frontend of myapp1 through the URL myapp.com. When I change it to</p>

<pre><code>      paths:
      - backend:
          serviceName: myapp2-service
          servicePort: 12345
        path: /(.*)
      - backend:
          serviceName: myapp1-service
          servicePort: 80
        path: /(.*)
</code></pre>

<p>I can reach the frontend of myapp2 through the URL myapp.com.</p>

<p>What I want to achieve is that I can reach the frontend of myapp1 through myapp.com and the frontend myapp.com/myapp2. Is that possible? And if so where is my mistake? As I've said, the frontend of myapp2 is basically accesible, just not through a sub-URL.</p>

TigersEye120
<p>Your path is configured to <code>/myapp2/(.*)</code> so <code>myapp.com/myapp2</code> does not match that. </p>

<p>Right now <code>myapp.com/myapp2</code> goes to <code>myapp1-service</code> looking for <code>/myapp2</code> content.</p>

<p>You can configure <code>/</code> at the end to be optional. But it will affect other path strings that match <code>myapp2</code>.</p>

<pre><code>tls:
  - hosts:
    - myapp.com
    secretName: my-certificate
  rules:
  - host: myapp.com
    http:
      paths:
      - backend:
          serviceName: myapp2-service
          servicePort: 12345
        path: /myapp2(/|$)(.*)
      - backend:
          serviceName: myapp1-service
          servicePort: 80
        path: /(.*)
</code></pre>

<p>It is also possible to rewrite <code>myapp.com/myapp2</code> to <code>myapp.com/myapp2/</code> but it is little bit more complicated on free version of nginx ingress.</p>

<p>Hope it helps.</p>
