Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

538
Vistas
Kubernetes Ingress path priority (ingress-nginx)

I deployed 2 front-end applications that are based on angular. I use ingress-nginx (k8s.gcr.io/ingress-nginx/controller:v0.44.0) with the following configurations to route the requests to these applications:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: portal-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - http:
      paths:
      - path: /?(.*)
        backend:
          serviceName: app1
          servicePort: 80
      - path: /app2
        backend:
          serviceName: app2
          servicePort: 80

When I hit the <ip-address>/ it is routing to app1, but when I hit <ip-address>/app2 it is routing back to app1.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

According to the ingress-nginx documentation, the first step it follows is to order the paths in descending length, then it transforms these paths into nginx location blocks. nginx follows a first-match policy on these blocks.

In your case, you can provide both paths, and as /app2 is longer than /, it will be written first in the nginx configuration. Meaning /app2 will have a chance to be matched first (and send the traffic to app2), while everything else will go to app1. You don't need regexes to achieve this.

Code:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: portal-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - http:
      paths:
      - path: /
        backend:
          serviceName: app1
          servicePort: 80
      - path: /app2
        backend:
          serviceName: app2
          servicePort: 80
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda