Nginx load balancing is more common, through the reverse proxy request to the respective different Server;
One advantage of the Nginx: Nginx can conduct their own health check and found that failure server will be automatically removed automatically added after the repair;
Here we need to 5 virtual machines for deployment;
Taiwan nginxserver responsible for reverse proxy load balancing;
4 as the Apache server; wherein two analog HTML; PHP simulation 2;
Configuration Nginx.conf
[root@sxb-1 conf]# vim nginx.conf upstream htmlserver { server 192.168.88.102:80; server 192.168.88.103:80; } upstream phpserver { server 192.168.88.104:80; server 192.168.88.105:80; } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location ~* \.html$ { proxy_pass http://htmlserver; } location ~* \.php$ { proxy_pass http://phpserver; }
Build a foundation we can use
test:
[root @ sxb- 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 102 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 102 html
[root @ sxb- 1 ~] # Curl 192,168 . 88,101 / index.php 104 php [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.php 105 php [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.php 104 php [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.php 105 php
Test automatically removed automatically add:
102 Strategies for firewall policy If you are adding DROP, the test will occur Caton; (DROP to drop, Nginx will continue to send until it times out;)
[root @ sxb- 1 ~] # iptables -t filter input -a -p TCP --dport 80 - j seventies [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 .88.101/index.html 103 html
Clear strategy:
[root @ sxb- 1 ~] # iptables - F [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 102 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 102 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 102 html [root @ bro - 1 ~] # Curl 192,168 . 88,101 / index.html Content 103 html