NGINX proxy_pass with URI modification

nginxproxypass

I need to pass some requests to proxy (running GlassFish) with removing one section of url.
For example:

https://xxx.net/jazz/MobileApi?id=2&make_id=4

Should be passed to proxy as:

http://X.X.X.X:8080/MobileApi?id=2&make_id=4

I have following Nginx configuration:

upstream vito_api {
    server 178.63.X.X:8080;
}

server {
    listen 80;
    listen 443 ssl;
    ....

    location ~ /jazz/(?<section>.*) {
       proxy_pass http://vito_api/$section/;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

But, unfortunately, request passing without parameters.
So, in GlassFish access logs, I can see only:

"148.251.X.X" "NULL-AUTH-USER" "05/Jan/2015:15:18:40 +0100" "GET /MobileApi/ HTTP/1.0" 200 21

What I did wrong?
How to pass URL parameters too?

Thank you.

Best Answer

From nginx's documentation (context : prefixed location)

If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive.

So it can be simplified with the following :

location /jazz/ {
    proxy_pass http://vito_api/;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}