是否可以在 Nginx 中使用 proxy_pass 删除查询字符串?例如,我将我的 nginx 称为:
http://nginxproxy.com/api/v1/logout?session=123
Run Code Online (Sandbox Code Playgroud)
并希望将其代理到:
http://example.com/api/sessions/?_action=logout
Run Code Online (Sandbox Code Playgroud)
没有查询字符串“session=123”。
目前我的设置只是添加我传递给 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;
}
Run Code Online (Sandbox Code Playgroud)
如果您要删除 上指定的任何查询字符串/api/v2/logout,添加set $args "";应该可以:
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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2263 次 |
| 最近记录: |