小编Mar*_*olo的帖子

HAProxy,对不同主机名的多台服务器进行健康检查

我需要在具有不同主机名的多个正在运行的服务器之间进行负载平衡。我无法在每个主机上设置相同的虚拟主机。

是否可以只对多个服务器进行一个监听配置并使健康检查应用该http-send-name-header Host指令?我正在使用 HAProxy 1.5。

我想出了这个工作 haproxy.cfg,正如你所看到的,我必须为每个健康检查设置一个不同的主机名,因为健康检查忽略http-send-name-header Host. 我更喜欢使用变量或其他方法并使事情更简洁。

global
    log 127.0.0.1 local0 notice
    maxconn 2000
    user haproxy
    group haproxy

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    timeout connect  5000
    timeout client  10000
    timeout server  10000
    stats enable
    stats uri /haproxy?stats
    stats refresh 5s
    balance roundrobin
    option httpclose

listen inbound :80    
    option httpchk HEAD / HTTP/1.1\r\n
    server instance1 127.0.0.101 check inter 3000 fall 1 rise 1
    server instance2 127.0.0.102 check …
Run Code Online (Sandbox Code Playgroud)

haproxy

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

haproxy ×1