This is my ingress and middle ware configuration yml file
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: demo-ingress
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: ingress-demo-test-stripprefix@kubernetescrd
kubernetes.io/ingress.class: traefik
namespace: ingress-demo
spec:
rules:
- host: nginx.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx-deploy-main
port:
number: 80
- path: /blue
pathType: Prefix
backend:
service:
name: nginx-deploy-blue
port:
number: 80
- path: /green
pathType: Prefix
backend:
service:
name: nginx-deploy-green
port:
number: 80
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-stripprefix
namespace: ingress-demo
spec:
stripPrefix:
prefixes:
- /green
- /blue
This works fine. But only works this way...
If I enter nginx.example.com/blue or nginx.example.com/green it works
But I need to config this as this way,
nginx.example.com/a/blue --> should strip /a and it should consider as /blue and directed to the nginx-deploy-blue service
nginx.example.com/a/b/c/blue --> should strip /a/b/c like above & should directed to the nginx-deploy-blue service
Same thing I need to do /green as well.
How to do that? I am tired searching on Traefik documentation to find a way to do that!