2016-07-26 200 views
0

我有兩臺服務器,每臺運行一個Wildfly應用程序服務器,並通過https提供一項服務。該服務正在關注https加密。在兩臺服務器前面,我有一個HAProxy作爲tcp模式下的負載均衡器,將ssl流量傳遞給這兩個服務。通過https 404狀態代碼在tcp模式下進行HAProxy運行狀況檢查

HAProxy運行狀況檢查僅檢查服務器是否聯機,而不是服務。如果該服務未運行,則Wildfly將返回:

<html><head><title>Error</title></head><body>404 - Not Found</body></html> 

HAProxy將其解釋爲健康。

HAProxy的配置:

global 
    maxconn 2000 

defaults 
    log  global 
    mode http 
    option dontlognull 
    retries 3 
    option redispatch 
    timeout connect 5000 
    timeout client 10000 
    timeout server 10000 

listen backend 
    bind *:8443 
    mode tcp 
    balance roundrobin 
    option httpclose 
    server backend1 wildfly:8443 check 
    server backend2 xxx.xxx.xxx.xxx:8443 check 

我怎樣才能讓HAProxy的理解404 - Not Found健康。

回答

1

兩行的伎倆:

  1. option httpchk /server
    • httpchk告訴HAProxy的發送HTTP請求,並檢查響應狀態
    • /server指定我的服務
    的URI /子
  2. server backend1 wildfly:8443 check check-ssl verify none
    • check-ssl告訴HAProxy的通過HTTPS檢查,而不是http
    • verify none告訴HAProxy的信任服務的SSL證書(alternativly你可以指定一個文件。質子交換膜)

完全HAProxy的配置:

global 
    maxconn 2000 

defaults 
    log  global 
    mode http 
    option dontlognull 
    retries 3 
    option redispatch 
    timeout connect 5000 
    timeout client 10000 
    timeout server 10000 

listen backend 
    bind *:8443 
    mode tcp 
    balance roundrobin 
    option httpchk /server 
    server backend1 xxx.xxx.xxx.xxx:8443 check check-ssl verify none 
    server backend2 xxx.xxx.xxx.xxx:8443 check check-ssl verify none