Configure Kubernetes Traefik Ingress with different path rewrites for each service Configure Kubernetes Traefik Ingress with different path rewrites for each service nginx nginx

Configure Kubernetes Traefik Ingress with different path rewrites for each service


After several hours of unsuccessful attempts to solve my issue, I did it with Nginx ingress controller and it works great! Here's the ingress configuration:

apiVersion: extensions/v1beta1kind: Ingressmetadata:  annotations:    nginx.ingress.kubernetes.io/configuration-snippet: |      rewrite /push/(.*) /index/$1 break;      rewrite /flights/(.*) /$1 break;      rewrite /grafana/(.*) /$1 break;spec:  rules:  - host: example.com    http:      paths:      - backend:          serviceName: pushinterface          servicePort: 80        path: /push      - backend:          serviceName: flights          servicePort: 80        path: /flights       - backend:          serviceName: api          servicePort: 80        path: /api      - backend:          serviceName: grafana          servicePort: 80        path: /grafana

Thanks to everyone for the answers! :)


Using ReplacePathRegex rule type in your example does not guarantee that incoming requests will be forwarded to the target backends, as mentioned in Traefik Documentation.

In order to route requests to the endpoints, use Matcher instead of Modifiers rules, as they are designed for that purpose.

Find a separate discussion on the similar issue here.