HAProxy hdr_dom(host)-i无法检测到subdomain.subdomain.domain.com

问题描述 投票:0回答:1

您好,我尝试使用haproxy中的acl将侦听同一端口的不同域名路由到不同的后端。当其中一个域名具有两个子域时,我会有问题。所以我的前端配置看起来像这样

bind *:80
mode http
acl is_foo hdr_dom(host) -i foo.foo.com
acl is_bar hdr_dom(host) -i bar.bar.bar.com
use_backend backend_foo if is_foo
use_backend backend_bar if is_bar
default_backend backend_default

[当我向bar.bar.bar.com发出请求时,请求转到backend_foo。谁可以帮我这个事?

haproxy
1个回答
0
投票

您的配置在HAProxy 2.0中对我有用。在下面,您可以看到我正在捕获客户端在请求日志中发送的Host标头,并被发送到每个主机的适当后端。

192.168.1.20:49506 [20/May/2020:23:29:33.869] fe_main backend_bar/s1 0/0/0/2/2 200 799 - - ---- 1/1/0/0/0 0/0 {bar.bar.bar.com} "GET / HTTP/1.1"

192.168.1.20:49508 [20/May/2020:23:29:35.799] fe_main backend_foo/s1 0/0/1/6/8 200 2080 - - ---- 1/1/0/0/0 0/0 {foo.foo.com} "GET / HTTP/1.1"
    bind *:80
    mode http
    http-request capture hdr(Host) len 32
    acl is_foo hdr_dom(host) -i foo.foo.com
    acl is_bar hdr_dom(host) -i bar.bar.com
    use_backend backend_foo if is_foo
    use_backend backend_bar if is_bar
    default_backend backend_default

backend backend_foo
   server s1 192.168.1.71:80

backend backend_bar
   server s1 192.168.1.122:80
© www.soinside.com 2019 - 2024. All rights reserved.