Apache Web Server Load Balancing Details of does not consider Session

  • 2020-07-21 07:07:12
  • OfStack

At least 3 servers are required:
Server A: Control server
Server B and Server C: the actual execution server
Principle of load balancing: Distribute requests to server A and server B for access
Modify http. conf file of apache on server A:

First, load the corresponding proxy module and remove the # in front of the following modules:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Second, add at the end of the file:
ProxyPass /example/ balancer://proxy/
< Proxy balancer://proxy >
BalancerMember http://serverB/example/
BalancerMember http://serverC/example/
< /Proxy >

Means to distribute all files under the http://serverA/example/ subdirectory of server A to servers B and C for execution, which is equivalent to accessing files under the http://serverB/ or http://serverC/example/ subdirectory.

If written:
ProxyPass / balancer://proxy/
< Proxy balancer://proxy >
BalancerMember http://serverB/
BalancerMember http://serverC/
< /Proxy >
It means that all requests for access to A are correspondingly converted to access to B or C
Finally, restart apache for server A


Related articles: