1.修改apache_home/conf/httpd.conf,增加以下模块(取消注释,如有其他依赖, 则相应取消注释)
LoadModule proxy_module modules
/mod_proxy
.so
LoadModule proxy_http_module modules
/mod_proxy_http
.so
LoadModule proxy_balancer_module modules
/mod_proxy_balancer
.so
2修改apache_home/conf/httpd.conf,配置VirtualHost实现负载均衡和会话保持,增加下面节点
<
VirtualHost
*>
Header add Set-Cookie "routeId=.%{BALANCER_WORKER_ROUTE}e;path=/" env=BALANCER_ROUTE_CHANGED
<!--设置cookie用来实现会话保持-->
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /myApp balancer://proxy/myApp stickysession=routeId
<!--取出设置的cookie, 转到相应的后端服务器-->
<
Proxy
balancer://proxy>
Order Deny,Allow
Allow from all
BalancerMember http://150.20.20.91:8001 route=server1
BalancerMember http://150.20.20.92:8001 route=server2
</
Proxy
>
</
VirtualHost
>