方法一
server { listen 80; server_name __proxy_resolver__; resolver 223.5.5.5;
set $proxy_schema 'http';
set $proxy_host '';
set $proxy_url '';
if ( $request_uri ~ (proxy_schema=([^&]+))){
set $proxy_schema $2;
}
if ( $request_uri ~ (proxy_host=([^&]+))){
set $proxy_host $2;
}
if ($request_uri ~ (proxy_url=(.*)$)){
set $proxy_url $2;
}
if ($proxy_url = '') {
return 404;
}
if ($proxy_host = '') {
return 404;
}
location / {
proxy_pass $proxy_schema://$proxy_host$proxy_url;
}
}
方法二
http://192.168.174.120/wbimg/?url=https://192.168.174.121/orj360/005UGUPIly1gwikvqim9rj31401404aa.jpg
server { listen 80; server_name 192.168.174.120; resolver 223.5.5.5;
location /~wbimg {
if ($query_string ~* ^(.)url=(.)$) {
set $url_ $2; #$2=https://192.168.174.121/orj360/005UGUPIly1gwikvqim9rj31401404aa.jpg
}
proxy_set_header Referer "https://weibo.com";
proxy_pass $url_;
}
}
URL截取 跳转
location ~ ^/token/(.*)$ {
return 302 http://www.baidu.com/top?tokenId=$1;
}
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:nginx 根据请求参数动态proxy_pass后端域名 - Python技术站