Haproxy不会在tcp模式下检查后端

时间:2016-05-24 06:15:37

标签: haproxy

在haproxy 1.5中检查健康状况时出现问题。 在sample-backend或sample-backend2中,haproxy不会在tcp模式下检查状态,即使我指定tcp模式,它也始终检查L7模式。它总是UP。

这是我的配置:

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

我的错误在哪里?谢谢!

1 个答案:

答案 0 :(得分:0)

我的版本是1.5.4,所以它在tcpcheck中有错误。更新到最新版本,它可以工作。