我有一个具有以下配置的HTTP场:
listen webfarm 10.254.23.225:80
mode http
balance roundrobin
cookie SERVERID insert
option httpclose
option forwardfor
option httpchk HEAD /check.txt HTTP/1.0
server webA 10.254.23.4:80 cookie A check
server webB 10.248.23.128:80 cookie B check
我想添加一些选项,将所有针对特定 URI(即 /special)的请求转发到第三个 Web 服务器。我该怎么做?
答案1
以下是我撰写的有关基于主机头的负载平衡的博客文章:
如果您想要匹配 URI 或目录,我建议使用 path_beg 而不是该页面示例中使用的 hdr_end。以下是如何使用您的配置执行此操作的示例:
frontend http-in
bind 10.254.23.225:80
acl has_special_uri path_beg /special
use_backend special_server if has_special_uri
default_backend webfarm
backend webfarm
balance roundrobin
cookie SERVERID insert
option httpchk HEAD /check.txt HTTP/1.0
option httpclose
option forwardfor
server webA 10.254.23.4:80 cookie webA check
server webB 10.248.23.128:80 cookie webB check
backend special_server
balance roundrobin
cookie SERVERID insert
option httpchk HEAD /check.txt HTTP/1.0
option httpclose
option forwardfor
server webC 10.0.0.1:80 cookie webC check
希望有帮助!