我有许多来自单个IP的请求,这些请求是以基本身份validation格式在HTTP头中提供的凭据。 即使来源相同,凭据在请求中也会频繁变化。
这是一个从内存caching中获得很多好处的API。 然而,为了使这个caching起作用,我需要能够将具有一组特定凭证的请求路由到同一台机器上。
这意味着我需要提出一个路由解决scheme,以某种方式将特定凭证“粘”到单台计算机上一段时间(30分钟),同时还以循环方式分发尚未附加的凭证。
这是可能的HAProxy?
是的,HAProxy可以平衡浏览器发送的任何请求头。 从手册 :
hdr(name) The HTTP header <name> will be looked up in each HTTP request. Just as with the equivalent ACL 'hdr()' function, the header name in parenthesis is not case sensitive. If the header is absent or if it does not contain any value, the round-robin algorithm is applied instead.
在基本身份validation的情况下,每个请求都将通过Authorization标头进行validation, Authorization标头采用Authorization: Basic <base64(username+password)> 。 所以在你HAProxyconfiguration下面应该工作:
... balance roundrobin balance hdr(Authorization) ...