Before a project needs to configure load balancing on Apache, because of the variety of things, time is tight, there is no time to get.
Today, the time to test a piece, at least can be a proxy.
You will now configure how the reverse proxy and load balancer are described separately.
1. Reverse Proxy
Steps:
(1) Open the reverse proxy module in Apache configuration file httpd.conf
#-----------------------------------------------
LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_connect_module
#-----------------------------------------------
(2) Add the following on the last side of the httpd.conf
#-----------------------------------------------
Namevirtualhost 10.0.0.1
<virtualhost 10.0.0.1>
ServerName www.baidu.com
Errorlog Logs/iis.log
Customlog Logs/iis.access.log Common
Proxypass/http://www.baidu.com
Proxypassreverse/http://www.baidu.com
</VirtualHost>
#-----------------------------------------------
(3) Enter HTTP://10.0.0.1/in the browser, you will find that the content of the page display is already http://www.baidu.com content.
2. Load Balancing
Steps:
(1) Open the reverse proxy module in Apache configuration file httpd.conf
#-----------------------------------------------
LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_connect_module
LoadModule Proxy_balancer_module modules/mod_proxy_balancer.so
#-----------------------------------------------
(2) Add the following on the last side of the httpd.conf
#-----------------------------------------------
Proxyrequests OFF
<proxy balancer://fzjh>
#loadfactor值越大, the greater the chance of being assigned.
Balancermember http://www.baidu.com loadfactor=2
Balancermember http://www.360.com loadfactor=1
Balancermember http://www.sina.com loadfactor=2
</Proxy>
Namevirtualhost 172.16.0.1
<virtualhost 172.16.0.1>
ServerName 172.16.0.1
#这个是根据流量来进行分发,
#ProxyPass/balancer://fzjh/lbmethod=bytraffic
proxypass/balancer://fzjh/
proxypassreverse/balancer://fzjh/
#ProxyPreserveHost on
</VirtualHost>
#-----------------------------------------------
(3) Enter the HTTP://172.16.0.1/in the browser, you will find that it will be assigned to baidu,360 or Sina according to the configuration situation.
Configure reverse proxy and load balancer configuration on Apache