1.安装 apache2
apt-get install apache2
2.加载代理模块:
a2enmod
proxy
proxy_ajp
proxy_balancer
proxy_connect
proxy_ftp
proxy_http
lbmethod_byrequests headers proxy_wstunnel
3.配置 000-default.conf
在<VirtualHost *:80>中添加一下代码
Header
add
Set-Cookie
"ROUTEID=.%{BALANCER_WORKER_ROUTE}e;
path=/"
env=BALANCER_ROUTE_CHANGED
ServerName localhost
ProxyRequests Off
ProxyVia On
<Proxy balancer://proxy>
Order Deny,Allow
Allow from all
#负载均衡服务器配置
BalancerMember http://192.168.72.136:8000 loadfactor=1 route=server1
#热备份服务器
BalancerMember http://192.168.72.133:8000 status=+H
BalancerMember http://192.168.72.135:8000 loadfactor=1 route=server3
</Proxy>
Proxypass /api balancer://proxy stickysession=ROUTEID
ProxyPassReverse /api balancer://proxy
<Proxy balancer://proxy1>
Order Deny,Allow
Allow from all
BalancerMember ws://192.168.72.136:8000 loadfactor=1 route=server1
BalancerMember ws://192.168.72.133:8000 status=+H
BalancerMember ws://192.168.72.135:8000 loadfactor=1 route=server3
</Proxy>
Proxypass /ws balancer://proxy1 stickysession=ROUTEID
ProxyPassReverse /ws balancer://proxy1
4.重新启动 apache
service apache2 stop
service apache2 start
或者 service apache2 restart
标签:负载,192.168,balancer,proxy,均衡,apache,ws,BalancerMember,8000 From: https://blog.51cto.com/u_16204217/9015164