I am in K8S and I have configured a nginx in reverse proxy so that calls to /api/img
are redirected to my service.
Example /api/img/123%2F456/123.png
-> http://service/123%2F456/123.png
The configuration is as follows:
location /api/img {
proxy_pass http://service/;
}
However, on my service I get the following url : http://service/123/456/123.png
How to avoid this ?
I have tried the following configurations (without success)
location /api/img {
rewrite ^/api/img(/.*) $1 break;
proxy_pass http://service;
}
-> http://service/123/456/123.png
location /api/img {
rewrite ^ $request_uri;
rewrite ^/api/img(/.*) $1 break;
return 400;
proxy_pass http://service;
}
-> no resolver defined to resolve service
location /api/img {
rewrite ^ $request_uri;
rewrite ^/test(/.*) $1 break;
return 400;
proxy_pass http://service$uri;
}
-> `no resolver defined to resolve service`
I don't want to define a resolver, because my configuration must be applied on any k8s cluster.
New contributor
Olivier is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.