For Nginx installation and Web service configuration, see: Ingress;
For Nginx installation and Web service configuration, see: http://www.linuxidc.com/Linux/2011-02/32410.htm
I. nginx reverse proxy configuration
Open the/etc/nginx. conf configuration file and add it to http:
Upstream ip {# external virtual IP Address
Server IP1;
Server IP2;
}
Server {
Listen 80;
Server_name ip; # I external virtual IP
Index index.php#index.html#index.htm;
Location /{
Proxy_pass http: // ip;
}
}
Ii. keepalived Configuration
1. Install Keepalived
Sudo apt-get install keepalived
2 configure keepalived
Use IP1 as the master server of Server Load balancer and IP2 as the slave server ". This is achieved through the priority in the configuration file. Set "master server" to 101 and "slave server" to 100.
On IP1, set/etc/keepalived. conf
$ Sudo nano/etc/keepalived. conf
Vrrp_script chk_haproxy {
Script "killall-0 haproxy"
Interval 2
Weight 2
}
Vrrp_instance VI_1 {
Interface eth0
State MASTER
Virtual_router_id 51
Priority 101 #101 is "master", 100 is "slave"
Virtual_ipaddress {
Ip # external virtual IP Address
}
Track_script {
Chk_haproxy
}
}
Run the keepalived Service
Sudo/etc/init. d/keepalived start
The configurations of IP2 and IP1 are basically the same. You only need to set the priority to 100.