kubernetes-ingress
kubernetes-ingress copied to clipboard
Does path rewriting support regex?
My yaml file likes
spec:
rules:
- host: my-host
http:
paths:
- path: /api/path1/
backend:
serviceName: dev-svc
servicePort: 80
- path: /api/path2/
backend:
serviceName: dev-svc
servicePort: 80
Is there a way I can rewrite
/api/path1/to/api/v1/path1//api/path2to/api/v1/path2/?
I tried
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: dev-ingress
namespace: dev
annotations:
nginx.org/rewrites: serviceName=dev-svc rewrite=/api/v1/$1
doesn't work.
Thanks.
Aha! Link: https://nginx.aha.io/features/IC-414
Hi @pistoolster thanks for reporting!
Be sure to check out the docs while you wait for a human to take a look at this :slightly_smiling_face:
Cheers!
I checked https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/ and https://github.com/nginxinc/kubernetes-ingress/tree/v2.1.0/examples/rewrites
can't get any idea
Hi @pistoolster
Unfortunately, we don't support regex in rewrites in Ingress resources. However, we do support them in VirtualServer resource -- https://github.com/nginxinc/kubernetes-ingress/tree/v2.1.0/examples/custom-resources/rewrites