我在 Ubuntu 上安装了 haproxy 1.8。我必须根据路径将流量路由到不同的后端。以下是 haproxy 的完整前端
frontend www_front
bind *:80
bind *:443 ssl crt /etc/haproxy/certs/example.com.pem alpn h2,http/1.1
# mode http
# option httplog
http-request capture req.hdr(Host) len 64
http-request track-sc0 src table per_ip_rates
http-request deny deny_status 429 if { sc_http_req_rate(0) gt 3000 }
http-request capture req.hdr(User-Agent) len 64
redirect scheme https if !{ ssl_fc }
# redirect IP based browsing
redirect prefix https://example.com code 301 if { capture.req.hdr(0) -i 210.56.21.204 }
acl is_admin path_beg -i /ader10/admin
redirect code 301 location /ader10 if is_admin
# ACLs
acl hss_req path_beg -i /hss/
use_backend ader10 if hss_req
acl api_req path_beg -i /api/v1/
use_backend hssApi if api_req
acl req1 path_beg -i /ima2
use_backend devApp if req1
acl piwik_url path_beg -i /piwik
use_backend piwik if piwik_url
acl andr_req path_beg -i /andr
use_backend mobile if andr_req
acl iss_req path_beg -i /iss
use_backend issDirApp if iss_req
acl niss_req path_beg -i /niss
use_backend iss125 if niss_req
acl ima_req path_beg -i /ima
use_backend imaApp if ima_req
acl irends_req path_beg -i /irends
use_backend irendsServer if irends_req
acl req_app1122 path_beg -i /app1122
use_backend irendsServer if req_app1122
acl ader10_req path_beg -i /ader10
use_backend ader10 if ader10_req
acl letsencrypt-acl path_beg /.well-known/acme-challenge/
use_backend letsencrypt-backend if letsencrypt-acl
default_backend apache
log-format %ci:%cp_[%t]_%bi:%bp_%s_%{+Q}r_%ST_%Tq/%Tw/%Tc/%Tr/%Tt_%B_%[capture.req.hdr(0)]
# LETSEncrypt Backend
backend letsencrypt-backend
server letsencrypt 127.0.0.1:8888
现在,当我测试 example.com/hss 时,有时会路由到正确的后端,有时会路由到默认后端(apache)。这是不正常的。问题出在哪里。同样,我观察到 /api/v1 有相同的行为。我通过日志记录和 curl 进行了很多调试,但没有成功。有人能帮忙看看问题出在哪里吗?全局设置几乎是默认的。