Nginx – HAProxy “503 Service Unavailable” for webserver running on a KVM virtual machine

haproxykvm-virtualizationnginx

I'm setting up a server with KVM (IP 192.168.0.100) and I have created inside of it one virtual machine using network bridging at 192.168.0.194. This virtual machine has an nginx instance running, which I can access from the server or from any computer computer in the internal network just typing in the browser http://192.168.0.194.

However, I try configure HAProxy in the same server that hosts KVM and looking the status page of HAProxy it always shows the virtual machine as "DOWN". If I try from the server http://localhost, it should be the same than if I go to http://192.168.0.194. My goal is to build a reverse proxy, but I tried this little example and won't work. What am I doing bad?

This is my config file in the server:

# /etc/haproxy/haproxy.cfg
global
        maxconn 4096
        user haproxy
        group haproxy
        daemon

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option  redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen ServerStatus *:8081
        mode    http
        stats   enable
        stats   auth haproxy:haproxy

listen Server *:80
       mode http
       balance roundrobin
       cookie JSESSIONID prefix
       option httpclose
       option forwardfor
       option httpchk HEAD /check.txt HTTP/1.0
       server mv1 192.168.0.194:80 cookie A check

Thanks.

Best Answer

Alright, I don't know what has happened but I changed this line option httpchk HEAD /check.txt HTTP/1.0 for this one option httpchk HEAD / HTTP/1.0 and start the server after starting HAProxy. Then it works as expected.