mod_proxy负载均衡LAMT基于mod_proxy调度使用基于mod_proxy负载均衡需要proxy_balancer_module (shared)模块的支持
修改mod_proxu.conf文件,添加两台tomcat主机,lb为负载均衡命名
[root@nginx-proxy2 conf.d]# cat mod_proxy.conf
ProxyVia on
ProxyRequests off
ProxyPreserveHost on
<Proxy balancer://lb>
BalancerMember http://10.0.0.53:8080 loadfactor=1 route=TomcatA
BalancerMember http://10.0.0.54:8080 loadfactor=1 route=TomcatB
</Proxy>
ProxyPass / balancer://lb/ stickysession=JSESSIONID
ProxyPassReverse / balancer://lb/
<Location />
Order Allow,Deny
Allow from all
</Location>
[root@nginx-proxy2 conf.d]#
stickysession=JSESSIONID
可以实现回话保持修改 workers.properties ,添加如下内容,分别是8009(mod_proxy可以http和ajp方式)
[root@nginx-proxy2 conf.d]# cat workers.properties
worker.list=lbcA,statA
worker.TomcatA.port=8009
worker.TomcatA.host=10.0.0.53
worker.TomcatA.type=ajp13
worker.TomcatA.lbfactor=1
worker.TomcatB.port=8009
worker.TomcatB.host=10.0.0.54
worker.TomcatB.type=ajp13
worker.TomcatB.lbfactor=1
worker.lbcA.type=lb
worker.lbcA.sticky_session=0
worker.lbcA.balance_workers = TomcatA,TomcatB
worker.statA.type = status
[root@nginx-proxy2 conf.d]#
状态信息
[root@nginx-proxy2 conf.d]# cat mod_proxy.conf
ProxyVia on
ProxyRequests off
ProxyPreserveHost on
<Proxy balancer://lb>
BalancerMember http://10.0.0.53:8080 loadfactor=1 route=TomcatA
BalancerMember http://10.0.0.54:8080 loadfactor=2 route=TomcatB
</Proxy>
ProxyPass / balancer://lb/
ProxyPassReverse / balancer://lb/
——————————————————————状态信息—————————————————————————
<Location /lbmanager>
SetHandler balancer-manager
</Location>
ProxyPass /lbmanager !
————————————————————————————————————————————————————————
<Location />
Order Allow,Deny
Allow from all
</Location>