0

I got 2 nginx servers which are handling 1) reverse proxy and 2) load balancing on two webservers. Since I cannot provide any of the nginx machines IP to the customer so I was thinking to have keepalived on top of 2 Nginx machines with VIP it also checks the fail-over of Nginx.

What I have achieved 1) Successfully installed nginx on 2 machines, so when I hit any nginx server IP I am able to see the application webpage. Even I tested the fail over it works fine.

2) I have installed keepalived on both the machines and tried to generate VIP with the following config

vrrp_script chk_nginx {
        script "killall -0 nginx"
        interval 2
}

vrrp_instance VI_1 {
        interface eth0:1
        state MASTER
        virtual_router_id 51
        priority 100
unicast_src_ip server1_ip
unicast_peer {
server2_ip
}
        virtual_ipaddress {
                VIP
        }
        track_script {
                chk_nginx
        }
}

--> So here when I hit VIP in the web browser I got following error This site can’t be reached

VIP refused to connect. Try: Checking the connection Checking the proxy and the firewall

Not sure what I am missing here . Can someone help me to resolve this issue .So as per my understanding when I hit VIP I should see application web page ?

Regards VG

user3332404
  • 411
  • 1
  • 4
  • 7
  • Do keepalived works? If you deatch the connection from one machine, it switch the virtual ip to the other? And can you ping something on the internet? – Federico Galli Jun 26 '17 at 15:17
  • Thanks Federico so by this you mean if I stop one machine VIP should assign to another machine and to check that I am firing ip a command and I can see the VIP on the second machine . Not sure if I am crosschecking it correctly . Is there any other way to check the fail over . Also I tried to ping www.google.com and I got nothing , it seems I am not allowed to ping or internet is not working on these machines . – user3332404 Jun 26 '17 at 15:37
  • It could be a routing issue, and you can fix it, but it would be best to understand if keepalived is working correctly first. You should setup keepalived, then you can try to switch off the ethernet connected to the keeping alive :-) (like.. ifconfig eth0 down for example) and see if the vip appear on the other server. So we can debug it then – Federico Galli Jun 26 '17 at 15:57

1 Answers1

0

Well the problem was with keepaived conf. I had mentioned wrong script check in the configuration . So for testing first I removed the script stenza , things works fine . Then I modified my script and then place the stenza in keepalived.conf. So to more specific this is what my script looks like

nginx.sh
if [ ! `ps -ec | grep nginx | awk '{ print $1 }'` ]; then service nginx start; fi;

Earlier I was missing semicolon in this script .Hope it will help someone .

user3332404
  • 411
  • 1
  • 4
  • 7