Reputation: 270
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;
}
Upvotes: 8
Views: 5234
Reputation: 15452
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;
}
Upvotes: 6
Reputation: 376
I believe you could do it with a rewrite rule like:
rewrite ^(.*)$ $1?;
Upvotes: 1