How to set sticky session across different URLs (Host Headers).

From: Unai Rodriguez <me#u-journal.org>
Date: Thu, 03 Apr 2008 03:12:47 -0600


Dear All,

I am currently load balancing a set of three web servers using HAProxy. Each of these servers is serving 5 different sites with one IP address only (i.e. using name based virtual hosting).

So, I have 5 different DNS names that resolve to the same IP address:

(DNS A record -> IP address)

----------------------------
a.example.com -> 1.2.3.4 b.example.com -> 1.2.3.4 c.example.com -> 1.2.3.4 d.example.com -> 1.2.3.4 e.example.com -> 1.2.3.4

Then, The Beast (a.k.a. HAProxy), doing the load balancing:



listen MYSITE 1.2.3.4:80
        mode    http
        cookie  SERVERID insert nocache
        balance roundrobin
        server  server1 10.123.7.112:80 cookie s1 check inter 1200 rise 2
fall 3
        server  server2 10.123.8.112:80 cookie s2 check inter 1200 rise 2
fall 3
        server  server3 10.123.9.112:80 cookie s3 check inter 1200 rise 2
fall 3
        option  abortonclose

--------------------------------------------------------------------------------------

I need to set session stickiness in such a way that whenever a client connects to one of the three web servers (10.123.7.112, 10.123.8.112 or 10.123.9.112) stays with it all the time.

This configuration is implementing session stickiness between request to THE SAME HOST NAME but not among the 5 different possible host names.

In other words, it would be possible that the client places a request to the following URL:

http://a.example.com/xxxxx

which would give her a cookie in the way:


    Name: SERVERID
 Content: s1
    Host: a.example.com
    Path: /
Send For: Any type of connection
 Expires: At end of session

--------------------------------------

granting her the subsequent requests to 'a.example.com' go to the server 10.123.7.112 (server1).

Now, she places another request to the URL:

http://b.example.com/yyyyy

producing the following cookie:


    Name: SERVERID
 Content: s3
    Host: b.example.com
    Path: /
Send For: Any type of connection
 Expires: At end of session

--------------------------------------

So, she would connect to 10.123.9.112 (server3).

How could I make her connect all the time to the same backend server (across the 5 different possible Hosts)?

I am running "HA-Proxy version 1.2.14 2006/05/21" under Debian Linux.

Thank you so much!!!
unai Received on 2008/04/03 11:12

This archive was generated by hypermail 2.2.0 : 2008/04/03 11:15 CEST