How does the rewrite annotation in ingress work in k8s?

10/30/2019

I am having difficulty in understanding the rewrite annotation in k8s ingress. Can someone please help me in understanding it with an example.

For Eg:

annotations:
   nginx.ingress.kubernetes.io/rewrite-target: /

I checked this Link out but it's still not very clear how the slashes and arguments work out here.

Thanks !

-- Naxi
kubernetes
kubernetes-ingress

1 Answer

10/30/2019

Please refer to this stackoverflow post, this will be helpful for you.

In this post you can see that hostname/api points to backend service, and the rewrite actually makes the url to get converted from hostname/api to hostname.

Rewrite comes handy when frontend and backend services are to be mapped to one hostname only

-- Tushar Mahajan
Source: StackOverflow