configurationHA代理以允许某些请求某些应用程序服务器

我有一个HaProxy设置,其中每个haproxy服务器将stream量路由到多个应用程序服务器。 正常httpstream量的路由基于请求url的散列。

现在我想创build一些规则来允许某些pipe理请求被路由到特定的应用程序服务器。 那就是我有应用程序服务器“node06 – node15”。 我希望能够请求node06.mydomain.com/my-admin-request并将其路由到正确的应用程序服务器。

我不能通过DNS来做到这一点。 所有请求都通过一个暴露的IP地址进入集群

所以我做了一个haproxyconfiguration,做我想要的:

frontend www-http bind :80 reqadd X-Forwarded-Proto:\ http acl node06 hdr_beg(host) -i node06. use_backend node06-status if node06 acl node07 hdr_beg(host) -i node07. use_backend node07-status if node07 # ... and many more such nodes ... default_backend application-backend # This is the application back end. # Route request based on hash of url backend application-backend balance url_param url check_post server node06 192.168.1.70:80 check server node07 192.168.1.71:80 check # ... and many more such nodes ... # these are the status back ends. This is so we can make requests # direct to each node for the status console. backend node06-status server node06 192.168.1.70:80 backend node07-status server node07 192.168.1.71:80 # ... and many more such back ends ... 

这将工作(我认为),但它真的罗嗦。 我必须为群集中的每个应用程序服务器创build三次相同的configuration块。 如果我把这个延伸超过10个节点,将会变得难以pipe理。

有没有一种方法来configuration这个,以便我不必为每个应用程序服务器分开configuration行?

您可以将ACL和use-server(而不是use-backend)放在后端定义中。 另外,我认为你可以使用内联ACL,而不必在使用之前定义它们。