Hi Daniel,

On Fri, May 03, 2013 at 01:57:35PM +0200, Daniel Storjordet wrote:
> Hi guys.
> 
> Is it possible to do load balancing based on a cookie, and if the cookie is
> not set, make HAProxy connect to a external service that returns a cookie
> value to HAProxy and make HAProxy assing this cookie before continue to the
> correct backend?

This looks somewhat related to what haproxy used to do, in its very first
implementation something like 12 years ago, except that it will not be able
to pass the reqeust to the backend server since the request is already lost
once sent to the cookie server.

> Example first time user:
> 1. Client connects, and no cookie is found.
> 2. HAProxy connects to IP/Port and gets a cookie value in return.
> 3. HAProxy sets this cookie.
> 4. HAProxy assigns backend based on cookie.

Use the "dispatch" statement for this, and have your cookie server use a
redirect. First-time visitors will be sent to the ip:port specified in
"dispatch", and this server will handle the request. If it performs a
redirect in addition to setting a cookie, the browser will send a new
request with the cookie and haproxy will pass it to the appropriate
server.

However it's still unclear to me why you'd rely on a specific server to
do this when haproxy does it for free by default.

Willy


Reply via email to