為什麼我的 HAProxy 內容切換配置會出錯?

為什麼我的 HAProxy 內容切換配置會出錯?

我正在將一些基礎設施從託管特定網站的多個伺服器遷移到使用負載平衡架構HA代理OpenBSD 4.6 macppc 上的 1.3.15.7。當然,我首先為目前設定(特定伺服器上的特定網站)配置內容切換,我的 /etc/haproxy/haproxy.cfg 如下:

global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 notice
    #log loghost    local0 info
    maxconn 1024
    chroot /var/haproxy
    uid 604
    gid 604
    daemon
    #debug
    #quiet
    pidfile /var/run/haproxy.pid

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    option  redispatch
    retries 3
    maxconn 2000
    contimeout      5000
    clitimeout      50000
    srvtimeout      50000
    stats enable
    stats auth user:pass

frontend http_proxy *:80
    # check to see which domain the reguest is for
    acl host_tld.domain.sub1 hdr_end(host) sub1.domain.tld
    acl host_tld.domain.sub2 hdr_end(host) sub2.domain.tld
    # send to the correct server
    use_backend server2 if host_tld.domain.sub1 or host_tld.domain.sub2
    default_backend server1

backend server1
    server httpd_server1 192.168.1.3:80

backend server2
    server httpd_server2 192.168.1.4:80

目標是為所有網域提供服務server1,但網域sub1.domain.tld&sub2.domain.tld應該由其分發server2。但是,當我嘗試啟動 HAProxy 時,出現以下錯誤:

parsing /etc/haproxy/haproxy.cfg : backend 'server2' has no dispatch address and is not in transparent or balance mode.
parsing /etc/haproxy/haproxy.cfg : backend 'server1' has no dispatch address and is not in transparent or balance mode.
Errors found in configuration file, aborting.
Error reading configuration file : /etc/haproxy/haproxy.cfg

我查看了中列出的範例HAProxy 1.3 文檔http://upstre.am/2008/01/09/using-haproxy-with-multiple-backends-aka-content-switching/,但不明白我哪裡出錯了。這些範例似乎都不需要option transparent平衡模式。另外,奇怪的是,1.3 文檔中省略了該選項的文檔dispatch,但我懷疑它對我的故障排除是否有幫助。

我哪裡出錯了?

答案1

您忘記了“平衡循環”(或同等內容)行,因為您需要在後端有一個平衡演算法。另外,您正在進行內容切換,因此請在前端或預設部分添加“option httpclose”,否則第二個保持活動連接的請求將不會被匹配。

相關內容