It seems to be a problem with my configuration file. I tried the one from Section 2.3 of haproxy.org/download/1.5/doc/configuration.txt, and it works good now:
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice daemon maxconn 256 defaults log global mode http timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend http-in bind *:80 default_backend servers backend servers server nginx-1 192.168.122.101:80 maxconn 32 server nginx-2 192.168.122.102:80 maxconn 32 Thanks, - KK On Tue, Apr 7, 2015 at 11:28 AM, Krishna Kumar Unnikrishnan (Engineering) < krishna...@flipkart.com> wrote: > Thanks Igor for the suggestion. I get: > > root@haproxy-2:/var/www# curl --http1.0 -X HEAD > 192.168.122.101:80/check.txt > curl: (18) transfer closed with 168 bytes remaining to read > root@haproxy-2:/var/www# curl --http1.0 -X HEAD > 192.168.122.102:80/check.txt > curl: (18) transfer closed with 168 bytes remaining to read > > And without the flags: > > root@haproxy-2:/var/www# curl 192.168.122.102:80/check.txt > <html> > <head><title>404 Not Found</title></head> > <body bgcolor="white"> > <center><h1>404 Not Found</h1></center> > <hr><center>nginx/1.6.2</center> > </body> > </html> > > Is this the problem? I am not sure how to fix it. > > Thanks, > - KK > > On Tue, Apr 7, 2015 at 11:10 AM, Igor Cicimov < > ig...@encompasscorporation.com> wrote: > >> >> >> On Tue, Apr 7, 2015 at 3:24 PM, Krishna Kumar Unnikrishnan (Engineering) >> <krishna...@flipkart.com> wrote: >> >>> Sorry, forgot to mention, this is haproxy version 1.5.11 >>> >>> >>> On Tue, Apr 7, 2015 at 10:52 AM, Krishna Kumar Unnikrishnan >>> (Engineering) <krishna...@flipkart.com> wrote: >>> >>>> Hi all, >>>> >>>> I am moving from using LXC to KVM for haproxy on my Debian 7 system. >>>> When I >>>> start haproxy, I get this error: >>>> _________________________________________ >>>> Apr 7 10:38:22 localhost haproxy[3418]: Proxy haproxy started. >>>> Apr 7 10:38:24 localhost haproxy[3420]: Server haproxy/nginx-1 is >>>> DOWN, reason Layer4 timeout, check duration: 2000ms. 1 active and 0 backup >>>> servers left. 0 essions active, 0 requeued, 0 remaining in queue. >>>> Apr 7 10:38:24 localhost haproxy[3419]: Server haproxy/nginx-1 is >>>> DOWN, reason Layer4 timeout, check duration: 2001ms. 1 active and 0 backup >>>> servers left. 0 essions active, 0 requeued, 0 remaining in queue. >>>> Apr 7 10:38:25 localhost haproxy[3420]: Server haproxy/nginx-2 is >>>> DOWN, reason Layer4 timeout, check duration: 2001ms. 0 active and 0 backup >>>> servers left. 0 essions active, 0 requeued, 0 remaining in queue. >>>> Apr 7 10:38:25 localhost haproxy[3420]: proxy haproxy has no server >>>> available! >>>> Apr 7 10:38:25 localhost haproxy[3419]: Server haproxy/nginx-2 is >>>> DOWN, reason Layer4 timeout, check duration: 2001ms. 0 active and 0 backup >>>> servers left. 0 essions active, 0 requeued, 0 remaining in queue. >>>> Apr 7 10:38:25 localhost haproxy[3419]: proxy haproxy has no server >>>> available! >>>> >>>> From outside the haproxy, I get the error: >>>> # wget 192.168.122.112:80 >>>> --2015-04-07 10:48:47-- http://192.168.122.112/ >>>> Connecting to 192.168.122.112:80... connected. >>>> HTTP request sent, awaiting response... 503 Service Unavailable >>>> 2015-04-07 10:48:47 ERROR 503: Service Unavailable. >>>> _______________________________________________________________ >>>> >>>> The config file is: >>>> global >>>> log 127.0.0.1 local0 >>>> log 127.0.0.1 local1 notice >>>> maxconn 65536 >>>> daemon >>>> quiet >>>> nbproc 2 >>>> debug >>>> user haproxy >>>> group haproxy >>>> >>>> defaults >>>> log global >>>> mode http >>>> option dontlognull >>>> retries 3 >>>> option redispatch >>>> maxconn 65536 >>>> timeout connect 5000 >>>> timeout client 50000 >>>> timeout server 50000 >>>> >>>> #listen haproxy 192.168.122.112:80 >>>> listen haproxy *:80 >>>> mode http >>>> stats enable >>>> stats auth someuser:somepassword >>>> balance roundrobin >>>> option prefer-last-server >>>> option forwardfor >>>> option httpchk HEAD /check.txt HTTP/1.0 >>>> >>> >> Check if the above health check is really working, you show that >> requesting the root page works but we don't see you checking the /check.txt >> file (does it exist at all?). Run: >> >> $ curl --http1.0 -X HEAD 192.168.122.101:80 <http://192.168.122.101/> >> /check.txt >> $ curl --http1.0 -X HEAD 192.168.122.102:80 <http://192.168.122.101/> >> /check.txt >> >> from the HAP server. >> >> server nginx-1 192.168.122.101:80 check >>>> server nginx-2 192.168.122.102:80 check >>>> >>>> BTW, I could not use "listen haproxy 192.168.122.112:80", but had to >>>> use *:80 >>>> as haproxy does not start up with the former. It seems like haproxy >>>> startup is >>>> happening ahead of networking. >>>> ______________________________________________________ >>>> >>>> I also stopped/restarted haproxy, but I still get the same error at >>>> start. >>>> >>>> root@haproxy-2:~# netstat -apn | grep :80 >>>> tcp 0 0 0.0.0.0:80 0.0.0.0:* >>>> LISTEN 3558/haproxy >>>> _______________________________________________________________ >>>> From outside haproxy, I can do a wget/curl" to either of the two >>>> servers: >>>> >>>> # wget 192.168.122.101:80 >>>> --2015-04-07 10:42:28-- http://192.168.122.101/ >>>> Connecting to 192.168.122.101:80... connected. >>>> HTTP request sent, awaiting response... 200 OK >>>> Length: 867 [text/html] >>>> Saving to: `index.html' >>>> >>>> 100%[======================================>] 867 --.-K/s in >>>> 0s >>>> >>>> 2015-04-07 10:42:28 (104 MB/s) - `index.html' saved [867/867] >>>> _______________________________________________________________ >>>> >>>> And I can do the same from haproxy: >>>> root@haproxy-2:~# wget 192.168.122.101 >>>> --2015-04-07 10:43:48-- http://192.168.122.101/ >>>> Connecting to 192.168.122.101:80... connected. >>>> HTTP request sent, awaiting response... 200 OK >>>> Length: 867 [text/html] >>>> Saving to: `index.html' >>>> >>>> 100%[======================================>] 867 --.-K/s in >>>> 0s >>>> >>>> 2015-04-07 10:43:48 (80.3 MB/s) - `index.html' saved [867/867] >>>> _______________________________________________________________ >>>> >>>> How do I fix this problem? >>>> >>>> Thank you, >>>> - KK >>>> >>> >>> >> >