
昨天,在大約 10 分鐘的時間裡,我的 haproxy 提供了許多 503 頁面(直接來自errorfile 503 /etc/haproxy/errors/503.http
),我不知道為什麼。我沒有對後端進行健康檢查,因此可以肯定這些沒有被標記為禁用。統計頁面未顯示已達到限制(在標記的紅色區域)。
global
maxconn 20000
tune.ssl.default-dh-param 2048
daemon
...
defaults
log global
mode http
timeout http-request 30s
option httplog
option dontlognull
timeout connect 5s
timeout server 120s
timeout client 30s
...
frontend frontend_for_all_sites
maxconn 20000
mode http
bind *:80
option http-buffer-request
timeout http-request 30s
...
use_backend www_backend if acl_hostname_www
use_backend static_backend if acl_hostname_static
backend www_backend
option forwardfor
server www localhost:9090 maxconn 5000
backend static_backend
option forwardfor
server s localhost:9090 maxconn 5000
接下來我應該看哪裡才能弄清楚為什麼會發生這種事?
答案1
你定了嗎default_backend
?
如果
use_backend www_backend if acl_hostname_www
use_backend static_backend if acl_hostname_static
失敗,沒有預設後端,因此503
答案2
這是後端,我設法指出在添加%ts
(termination_state)後發生了什麼log-format
,這樣我就可以驗證後端確實不可用。