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

366
Vistas
Kubernetes Ingress Path

I have nginx-ingress setup for both frontend and backend using below yaml file.

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: polls-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/service-upstream: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - example.com
    secretName: polls-tls
  rules:
  - host: example.com
    http:
      paths:
      - path: /(.*)
        backend:
          serviceName: frontend
          servicePort: 3000
      - path: /graphql/(.*)
        backend:
          serviceName: polls
          servicePort: 8000

Currently, my rewrite-target reroutes as below

example.com  => / of frontend app
example.com/ => / of frontend app
example.com/graphql => / of frontend app
example.com/graphql/post => / of frontend app

example.com/graphql/ => / of backend app
example.com/graphql/post/ => /post of backend app

But I want the backend app to be used for both graphql/post and graphql/post/ as below.

example.com => / of frontend app
example.com/ => / of frontend app
example.com/hello => /hello of frontend app
example.com/test => /test of frontend app

example.com/graphql => / of backend app
example.com/graphql/ => / of backend app
example.com/grpahql/post => /post of backend app
example.com/graphql/post/ => /post of backend app

Could anyone tell me how to achieve it?

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

0

You need to change the regex for graphql path like the following:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: polls-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/service-upstream: "true"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
  tls:
  - hosts:
    - example.com
    secretName: polls-tls
  rules:
  - host: example.com
    http:
      paths:
      - path: /(.*)
        backend:
          serviceName: frontend
          servicePort: 3000
      - path: /graphql/?(.*)   # <- HERE add "?"
        backend:
          serviceName: polls
          servicePort: 8000

From docs on regex:

The question mark indicates zero or one occurrences of the preceding element. For example, colou?r matches both "color" and "colour".

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