Kubernetes ingress location rewrite

6/29/2017

We are planning to move out of using normal nginx pods in our platform since managing config (and reloading nginx after config change) gets really tricky and has lots of scope for bugs. I am doing a POC to use nginx ingress controller, everything working great but one issue regarding rewriting request uri. In our old approach we had something like this in our nginx conf:

upstream test {
  ...
}    
location ~ ^/v1/resources/([^/]+)(.*)$ {
  proxy_pass http://$1$2; # Serving application requires rewrite in such a manner

e.g. request uri -> http://host:port/v1/resources/test

Now how do I achieve same thing with ingress. I have looked at ingress.kubernetes.io/rewrite-target annotation but that does not solve our problem (right?). Any help is much appreciated.

-- Pravin Gadakh
kubernetes
nginx
nginx-location

0 Answers