Artyom Davydov
Artyom Davydov

Reputation: 11

Haproxy doesnt check backend in tcp mode

there is a problem with checking health status in haproxy 1.5. In sample-backend or sample-backend2 haproxy doesnt check status in tcp mode, it always checks in L7 mode even if i specify tcp mode. And it always UP.

Here is my config:

global
log         127.0.0.1 local2
chroot      /var/lib/haproxy
pidfile     /var/run/haproxy.pid
maxconn     4000
user        haproxy
group       haproxy
daemon
defaults
mode                    tcp
log                     global
option                  httplog
option                  dontlognull
option http-server-close
option forwardfor       except 127.0.0.0/8
option                  redispatch
retries                 3
timeout http-request    10s
timeout queue           1m
timeout connect         10s
timeout client          1m
timeout server          1m
timeout http-keep-alive 10s
timeout check           10s
maxconn                 3000

frontend haproxy_in
    mode http
    bind 172.25.0.33:80
    option forwardfor header X-Real-IP

    acl host_static hdr_beg(host) -i sample.
    use_backend sample-backend if host_static

    acl host_static hdr_beg(host) -i af-ws.
    use_backend sample-backend if host_static

    default_backend haproxy_http

frontend haproxy_in_htpps
    bind 172.25.0.33:443
    mode tcp
    use_backend haproxy_https

backend haproxy_https
    balance roundrobin

    mode tcp
    option httpchk OPTIONS /manager/html
    http-check expect status 401
    option forwardfor
    server web1 172.25.0.35:443 check addr 172.25.0.35 port 8085 inter 5000
    server web2 172.25.0.36:443 check addr 172.25.0.36 port 8085 inter 5000

backend haproxy_http
    balance roundrobin
    mode http

    option httpchk
    option forwardfor
    server web1 172.25.0.35:80 check
    server web2 172.25.0.36:80 check backup

backend sample-backend
    mode http
    balance roundrobin
#       option httpchk get /?action=Ping
#       option forwardfor
    option tcp-check
#       server web4 172.25.0.38:80 check addr 172.25.0.38 port 8888 inter 5000
#       server web3 172.25.0.37:80 check addr 172.25.0.37 port 8888 inter 5000
    server test 10.41.41.240:8888 check addr 10.41.41.240 port 8888 inter 5000
    server test1 172.25.0.37:9999 check addr 172.25.0.37 port 9999 inter 5000

backend sample-backend2
    mode tcp
    balance roundrobin
#       option httpchk get /?action=Ping
#       option forwardfor
    option tcp-check
#       server web4 172.25.0.38:80 check addr 172.25.0.38 port 8888 inter 5000
#       server web3 172.25.0.37:80 check addr 172.25.0.37 port 8888 inter 5000
    server test2 10.41.41.240:8888 check addr 10.41.41.240 port 8888 inter 5000
    server test3 172.25.0.37:9999 check addr 172.25.0.37 port 9999 inter 5000

Where is my mistake ? Thanks!

Upvotes: 0

Views: 3292

Answers (1)

Artyom Davydov
Artyom Davydov

Reputation: 11

My version was 1.5.4 , so it has bug in tcpcheck. Update to latest version and it works.

Upvotes: 1

Related Questions