I'm trying to rewrite the path to the service while preserving the browser url with nginx ingress on kubernetes.
What I need is this:
http://example.com/path
=>http://service
http://example.com/path/bar
=>http://service/bar
http://example.com/path/file.css
=>http://service/file.css
That is, make the /path
be the root (or some different url) in the upstream server.
From what I see here, this is done using a trailing slash on the proxy_pass, but nginx ingress doesn't seem to have this option.
Is this possible nginx ingress?
Best Answer
Yes, In order to achieve it you can use
rewrite-target
.It will create a capture group and send it to the appropriate service. Here is an Ingress example:
This ingress will do the following:
Example:
If you have any question let me know in the comments.