Answer the question
In order to leave comments, you need to log in
How to change request in nginx with proxy_pass?
There is a task to redirect request. In a simple way, everything works fine:
location /api/v2/test/query {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:11111/api/v1/test/query;
}
location /api/v2/test/-|[0-9a-fA-F]+/query {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:11111/api/v1/test/-|[0-9a-fA-F]+/query;
}
Answer the question
In order to leave comments, you need to log in
location ~ ^/api/v2/test/((-|[0-9a-fA-F]+)/query.*) {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:11111/api/v1/test/$1;
}
And what does not work in such a simple version?
location /api/v2/test/ {
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:11111/api/v1/test/;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question