I am trying to achieve HA for 2 nginx load balancers. So i have 3 centos linux os docker containers - nginx and keepalived are running in 2 of the containers, while the third container is just a test container. Now i have successfully configured nginx and keepalived to achieve high availability and i am able to test my setup successfully using curl from the test container
curl http://172.19.0.200:80/api/v1/dev/home
The above curl command returns the expected outcome - 172.19.0.200 is the virtual ip set in the keepalived conf
#keepalived1
vrrp_script chk_nginx {
script "/etc/keepalived/check_nginx.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 70
priority 100
nopreempt
advert_int 1
authentication {
auth_type PASS
auth_pass password
}
virtual_ipaddress {
172.19.0.200
}
track_script {
chk_nginx
}
}
#keepalived2
vrrp_script chk_nginx {
script "/etc/keepalived/check_nginx.sh"
interval 2
weight 2
}
vrrp_instance VI_2 {
state BACKUP
interface eth0
virtual_router_id 70
priority 90
nopreempt
advert_int 1
authentication {
auth_type PASS
auth_pass password
}
virtual_ipaddress {
172.19.0.200
}
track_script {
chk_nginx
}
}
And the below conf is that of nginx.conf
error_log /var/log/nginx/error.log;
http {
upstream all {
server signup1:3000 max_fails=3 fail_timeout=10;
server signup2:3220 max_fails=3 fail_timeout=10;
}
server {
listen 172.19.0.200:80;
location / {
proxy_pass http://all;
#health_check interval=10 fails=3 passes=2;
}
}
}
I assume that if i enter: http://172.19.0.200:80/api/v1/dev/home on a browser like chrome, i should see my desired output, but nothing happens. Instead it loads for sometime, stops, loads again, stops, and then simply displays: This site can’t be reached, 172.19.0.200 took too long to respond. So my question is: how do i access my upstream servers from chrome or any other browser using the virtual ip address.