upstream apache {
server 127.0.0.1:8080;
}
server{
location ~* ^/service/(.*)$ {
proxy_pass http://apache/$1;
proxy_redirect off;
}
}
The above snippet will redirect requests where the url includes the string “service” to another server, but it does not include query parameters.
From the proxy_pass documentation:
Since you’re using $1 in the target, nginx relies on you to tell it exactly what to pass. You can fix this in two ways. First, stripping the beginning of the uri with a proxy_pass is trivial:
Or if you want to use the regex location, just include the args: