HAproxy-如何在没有任何路径的情况下匹配给定的URL?

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

我想使用完全匹配的网址转发流量,例如在给定的前端中具有ACL规则的test.example.com。当test.example.com\path时,应移至另一个后端。我的设置有点复杂,这意味着仅为给定后端的路径指定acl匹配对我不起作用。

[ACL逻辑:将后端IF acl_match_exact_url用于其他一切acl_use_other_backend。

是否只有通过ACL URL的方法?

url match acl haproxy
1个回答
0
投票
如果我正确理解了您的问题,则需要一个可以按主机标头和/或路径进行匹配的ACL。您可以通过多种方式进行操作,例如,可以分别匹配req.hdr(host)path,如下所示:

acl match_path path /path acl match_host req.hdr(host) test.example.com use_backend backend_one if match_path match_host default_backend backend_two

您也可以使用base进行此操作,该操作将主机和路径连接到一个样本中,例如:

acl match_host_and_path base test.example.com/path use_backend backend_one if match_host_and_path default_backend backend_two

© www.soinside.com 2019 - 2024. All rights reserved.