Is it possible to remove query strings using proxy_pass in Nginx? For example i call my nginx on:
http://nginxproxy.com/api/v1/logout?session=123
And would like to proxy this to:
http://example.com/api/sessions/?_action=logout
Without the query string "session=123".
Currently my setup just adds any query string i pass to the proxy_pass URL.
location /api/v2/logout {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Session $arg_token;
proxy_pass http://example.com/api/sessions/?_action=logout;
}
If you're looking to remove any query string specified on /api/v2/logout
, adding set $args "";
should work:
location /api/v2/logout {
set $args "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Session $arg_token;
proxy_pass http://example.com/api/sessions/?_action=logout;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With