2016-04-28 61 views
1

我有一個網站由haproxy負載均衡器後面的多臺機器提供服務。現在它使用基於cookie的粘性會話。我正在使用uptimerobot來檢查機器的健康狀況,但我無法將其配置爲使用cookie,我不希望loadbalancer成爲互聯網唯一的開放點。可以訪問haproxy負載均衡器後面的特定機器進行健康檢查

有沒有辦法配置負載均衡器通過url參數訪問機器?

回答

1

有一種方法,但不建議。在配置中,創建重複的後端塊和基於url_param的ACL,以根據URL參數將請求路由到特定服務器。

例子:

frontend fe 
    bind x.x.x.x:80 
    bind x.x.x.x:443 ssl crt.. blah 
    ... 
    default_backend www 

    acl is_healthchk_s1 url_param(CHECK) -i s1 
    acl is_healthchk_s2 url_param(CHECK) -i s2 
    acl is_healthchk_sn url_param(CHECK) -i sn 

    use_backend be_healthchk_s1 if is_healthchk_s1 
    use_backend be_healthchk_s2 if is_healthchk_s2 
    use_backend be_healthchk_sn if is_healthchk_sn 

backend www 
    server s1 x.x.x.x:8080 check 
    server s2 x.x.x.x:8080 check 
    server sn x.x.x.x:8080 check 

backend be_healthchk_s1 
    server s1 x.x.x.x:8080 check 
backend be_healthchk_s2 
    server s2 x.x.x.x:8080 check 
backend be_healthchk_s3 
    server s3 x.x.x.x:8080 check 

所以,你的正常運行時間機器人可以代替檢查這些:

  • domain.com/?CHECK=s1
  • domain.com/?CHECK=s2
  • domain.com/?check=sn
相關問題