客户端发起请求,需要Web代理服务器根据请求(GET和POST)的参数代理到不同的后端服务器,请选择Web代理软件并简述实现的过程?
nginx
只需在nginx的location块下配置相应请求的路由
列如:
location/{
root /usr/share/nginx/html;
index index.htmlindex.htm;
if($request_uri~*\.html$){
proxy_passhttp://htmlserver;
}
再在nginx的相应子配置文件中配置upstream
如:
upstream htmlserver{
server192.168.122.10;
server192.168.122.20;
}
编写nginx
rewrite规则,http://192.168.1.1/ops/index.php/admin/idc转化成http://192.168.1.1/ops/index.php?act=admin&arg=idc?
location~*/ops/index.php/admin/(.*)${
rewrite/ops/index.php/admin/(.*)/ops/index.php?act=admin&arg=$1last;
}