nginx转发
1、nginx.conf 配置
map $arg_xxx $proxy_url {
"aaa" /aaa_url;
"bbb" /bbb_url;
default /default_url;
}
server {
...
location = /proxy.html {
rewrite ^ $proxy_url last;
}
location = /aaa_url{
proxy_pass http://aaa.com/;
}
location = /bbb_url{
proxy_pass http://bbb.com/;
}
location = /default_url{
proxy_pass http://default.com;
}
...
}
根据以上配置:
当url中带参数 xxx 时 根据不同值转发,例:
1、https://www.domain.com/proxy.html?xxx=aaa 时 转发到 http://aaa.com
2、https://www.domain.com/proxy.html?xxx=bbb 时 转发到 http://bbb.com
3、https://www.domain.com/proxy.html?xxx=其他值 时 转发到 http://default.com