【发布时间】:2021-08-08 07:38:42
【问题描述】:
如何通过 nginx 的 proxy_pass 转发 URL 的所有参数?
Nginx 配置:
location /proxy/ {
if ($request_method = HEAD) { return 200; }
if ( $arg_address != "" ) {
proxy_pass $arg_address;
return 301 $arg_address;
}
proxy_ssl_verify off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
这个网址有效:
https://localhost/proxy/?address=https://exemple.com/transfer/file.txt ==>> https://exemple.com/transfer/file.txt
或
https://localhost/proxy/?address=https://exemple.com/transfer/file.txt?host-id=1 ==>> https://exemple.com/transfer/file.tx?host-id=1
如果我添加多个参数,它会被截断为第一个“&”
https://localhost/proxy/?address=https://exemple.com/transfer/file.txt?host-id=1&password=123456&date=xxxxxx ==>> https://exemple.com/transfer/file.txt?host-id=1
如何转移整个网址?
【问题讨论】:
标签: nginx parameters nginx-config proxypass