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

375
Vistas
why redirect (server-side) to root on nginx ingress (reverse proxy) & rewrite-target

I'm using Kubernetes with Nginx ingress controller and I have two services (srv1 and srv2) on my namespace which I want to access them like this:

https://xyz.example.com/srv1/ => (point to the root of srv1)
https://xyz.example.com/srv2/ => (point to the root of srv2)

for example, if someone hit the below URL :

https://xyz.example.com/srv1/page1.aspx

then, they will hit the page1.aspx which is in the root of my application in srv1

it works just fine with the below ingress file:

Problem:

I have a second page which is page2.aspx and I placed it next to page1.aspx, so both of them are in root, now if I click on a button on the page1 which has a server-side code to redirect us to the page2.aspx, then I expected to get us into the below URL:

https://xyz.example.com/srv1/page2.aspx

but instead, it will redirect me to the below path:

https://xyz.example.com/page2.aspx

Just for clarification, I put an HTML link in the page1 which point to page2, it works just fine because it works in the client-side instead of the server-side.

so far I used the below 3 languages for the server-side redirection and all of them have the same behaviour:

C# & .net core (versions 2.1 , 2.2 , 3.0 and 3.1)
Python (version 3.7)
Ruby (version 2.7.1)

so I think the problem is from Kubernetes, anyone has any idea?

here are my ingress YAML:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ds1-ingress
  namespace: ds1
  annotations:
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  tls:
  - hosts:
    - xyz.example.com
    secretName: tls-secret
  rules:
  - host: xyz.example.com
    http:
      paths:
      - backend:
          serviceName: srv1
          servicePort: 80
        path: /srv1/(.*)
      - backend:
          serviceName: srv2
          servicePort: 80
        path: /srv2/*
  • Github's link for source-code:

https://github.com/POC-Vault/Routing

  • Docker-hub' link for anyone who likes to pull the image and test it.

https://hub.docker.com/repository/docker/farzadjalali/k8s-routing

  • How to pull the docker image:

    docker push farzadjalali/k8s-routing:latest

over 4 years ago · Santiago Trujillo
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