Sorry i'm new to all that, i have 2 springboot app deployed and exposed (using services) which i can reach using < Minikube IP >:< Port > and i want to use ingress to expose the apps.
I've this ingress config to expose 2 kubernetes services.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: esse-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: mssmdns.dz
http:
paths:
- path: /esse-1/*
backend:
serviceName: esse-service-1
servicePort: 8080
- path: /esse-2/*
backend:
serviceName: esse-service-2
servicePort: 8080
I want to redirect incoming request as follow:
http://mssmdns.dz/esse-1/a/b/c (from outside) -> http://mssmdns.dz/a/b/c (inside the app)
(and same for esse-2).
When i write any url i'm being stuck in the same page (the / url) I'm using kubernetes and nginx as ingress controller.
thanks in advance
The ingress-nginx documentation provides an example rewrite configuration.
It uses regular expressions on the path and then uses the second matching group from the regex in the rewrite-target
annotation.
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: esse-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
- host: mssmdns.dz
http:
paths:
- path: /esse-1(/|$)(.*)
backend:
serviceName: esse-service-1
servicePort: 8080
- path: /esse-2(/|$)(.*)
backend:
serviceName: esse-service-2
servicePort: 8080