Ingress Support for URL Rewrite (NSX-T only)
Page last updated:
Warning: VMware Enterprise PKS v1.6 is no longer supported because it has reached the End of General Support (EOGS) phase as defined by the Support Lifecycle Policy. To stay up to date with the latest software and security updates, upgrade to a supported version.
This topic describes how to perform URL rewrite for Kubernetes ingress resources.
Enterprise PKS with NSX-T supports ingress URL path rewrite using NSX-T v2.5.1+ and NCP v2.5.1+.
All the ingress paths will be rewritten to the provided value. If an ingress has annotation
ingress.kubernetes.io/rewrite-target: / and has path
/tea, for example, the URI
/tea will be rewritten to
/ before the request is sent to the backend service. Numbered capture groups are supported.
The following example shows how to implement URL rewrite.
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: cafe-ingress annotations: kubernetes.io/ingress.class: "nsx" ncp/use-regex: "True" #/tea/cup will be rewritten to /cup before sending request to endpoint ingress.kubernetes.io/rewrite-target: /$1 spec: rules: - host: cafe.example.com http: paths: - path: /tea/(.*) backend: serviceName: tea-svc servicePort: 80 - path: /coffee/(.*) backend: serviceName: coffee-svc servicePort: 80
Please send any feedback you have to firstname.lastname@example.org.