我怎样才能使haproxy路由请求基于URL子string?

负载平衡器设有两个后端。

请求URI将如下所示:

http://example.com/answers/submit http://example.com/tag-02/answers/submit 

如何configurationhaproxy,使得请求被发送到两个后端中的一个或另一个,具体取决于请求URI的格式? 请求URI中的唯一区别是/tag-02/

一个haproxyconfiguration文件这一点有点解释将不胜感激,因为我是haproxy新手。

你想使用ACL :

 backend be1 # this is your default backend ... backend be2 # this is for /tag-02 requests ... frontend fe ... default_backend be1 acl url_tag02 path_beg /tag-02 use_backend be2 if url_tag02 

“ HAProxyconfiguration指南”的第7部分详细介绍了ACL,但您必须知道指南第4.2节中隐藏的magic use_backend咒语,才能知道如何处理ACL。