I am trying to route the traffic from an nginx, to a specific IP, corresponding to a path.
Basically if I am accessing http://example.com/192.168.0.2/something
, I want to redirect the traffic to the pod with that specific IP (the result should be https://192.168.0.2/something
).
I tried this (and multiple variations) but it doesn't seem to work.
location ~* "([0-9]{0,3}\.[0-9]{0,3}\.[0-9]{0,3}\.[0-9]{0,3})\/(.*)" {
proxy_pass http://192.168.219.174:8080$uri;
proxy_set_header Host $host;
}
I even tried a static version (and multiple variations) like below
location ~* "/test/" {
rewrite "/test/(.*)" /$1 break;
proxy_pass http://192.168.219.174:8080
proxy_set_header Host $host;
}
Is there any way to achieve this?