Ingress on root colliding with ingress on path

4/2/2019

I have two containers - one that is a static page in nginx and second one that is react app.

I would like to serve static page on / and react app on /app

Currently the problem is that when I enter / I have redirect on /app

Excerpt of helm for static page:

ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/app-root:  /
  paths:
    - /

Excerpt of helm for react app:

ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/app-root: app/
  paths:
    - /app

kubectl describe ingress:

Name:             app
Namespace:        prod
Address:          
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host              Path  Backends
  ----              ----  --------
  example.com  
                    /app   app:http (10.244.2.52:80)
Annotations:
  kubernetes.io/ingress.class:           nginx
  nginx.ingress.kubernetes.io/app-root:  app/



Name:             static-page
Namespace:        prod
Address:          
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host              Path  Backends
  ----              ----  --------
  example.com  
                    /   static-page:80 (10.244.2.40:80)
Annotations:
  kubernetes.io/ingress.class:           nginx
  nginx.ingress.kubernetes.io/app-root:  /
-- pixel
kubernetes-helm
kubernetes-ingress
nginx-ingress

1 Answer

4/2/2019

You might try to use multipath configuration within one ingress object without nginx.ingress.kubernetes.io/app-root: annotation, it works for me in similar scenario:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: example
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: static-page
          servicePort: 80
        path: /
      - backend:
          serviceName: app
          servicePort: 80
        path: /app
-- mk_sta
Source: StackOverflow