I have a REST API URL:
http://localhost:4000/api/v2/stocks/accounts/1162/tradings
I want it to be proxy_pass for the URL:
http://localhost:4001/api/v2/stocks/accounts/1162/tradings
Where 1162 is a URL parameter, which may be a different value.
I have the following:
location ^~ /api/v2/stocks/accounts/([^/]+)/tradings {
proxy_pass http://localhost:4001/api/v2/stocks/accounts/$1/tradings;
}
But it does not work (404 Not Found), I have a similar problem in googled, but it doesn't help much:
Like this one: Get nginx arguments and path for proxy_pass or this: problem with location regex and redirect in nginx .
Is there a way to achieve what I want using nginx?
Thanks in advance for your help.
ADDED:
I also added parameter capture:
location ~ /api/v2/stocks/accounts/([^/]+)/tradings/(.*) {
proxy_pass http://localhost:4001/api/v2/stocks/accounts/$1/tradings/$2$is_args$args;
}
source
share