参考地址:https://www.cnblogs.com/w787815/p/6658269.html
编辑linux-node2的apache作为反向代理的配置文件
[root@linux-node2 extra]# pwd #路径
/usr/local/httpd-2.4.23/conf/extra
[root@linux-node2 extra]# cat httpd-proxy.conf
#www.check-blog.com
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
ProxyRequests Off
<Proxy balancer://check-cluster>
BalancerMember http://192.168.230.129:8080
BalancerMember http://192.168.230.128:8080
</Proxy>
ProxyPass /demo balancer://check-cluster
ProxyPassReverse /demo balancer://check-cluste
#www.check-blog.com
LoadModule proxy_module modules/mod_proxy.so #proxy模块
LoadModule proxy_connect_module modules/mod_proxy_connect.so #链接的模块
LoadModule proxy_http_module modules/mod_proxy_http.so #给http做代理模块
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so #负载均衡模块
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so #算法模块,根据server的请求量
LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so #算法模块,根据server流量
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so #算法模块,根据server繁忙程度
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so #
ProxyRequests Off #如果没有对服务器采取安全措施之前,请不要开启此项
<Proxy balancer://check-cluster> #lb集群组的名称
BalancerMember http://192.168.230.129:8080 #集群组成员
BalancerMember http://192.168.230.128:8080 #集群组成员
</Proxy>
ProxyPass /demo balancer://check-cluster #跳转,和lb集群组名称对应,访问demo
ProxyPassReverse /demo balancer://check-cluster
将刚才的文件包含
[root@linux-node2 extra]# vim /usr/local/httpd-2.4.23/conf/httpd.conf +482
# Proxy demo
Include conf/extra/httpd-proxy.conf
检查语法
[root@linux-node2 extra]# /usr/local/httpd/bin/apachectl -t
Syntax OK
重启
[root@linux-node2 extra]# /usr/local/httpd/bin/apachectl -k restart