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)
So it can be simplified with the following :