ydder
By:
ydder

haproxy appcookie is not working.

September 10, 2015 1.2k views
Load Balancing

Hi,

We have the haproxy configuration where two VM are behind the LB device. We are using linux virtual router as LB device. The http request from the public side is going to two vms on round robin basis, it is honouring the session cookie.
Please let us know if we are missing any thing in harpy config.

Below the configuration details; Public ip: 10.220.166.226, private/http server tips: 10.10.1.89, 10.10.1.242
Haproxy version: HA-Proxy version 1.5.8 2014/10/31
Haproxy configuration:

listen 10_220_166_226-80 10.220.166.226:80
        balance roundrobin
        server 10_220_166_226-80_0 10.10.1.242:80 check cookie 10_10_1_242-80
        server 10_220_166_226-80_1 10.10.1.89:80 check cookie 10_10_1_89-80
        appsession escalation len 37 timeout 30m
        mode http
        option httpclose

Output:

[root@CS-MS-1167580 ~]# curl -i http://10.220.166.226/session.php
HTTP/1.1 200 OK
Date: Wed, 09 Sep 2015 07:11:02 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Set-Cookie: PHPSESSID=pvlqa66cus9837vcvqgap9kjb5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 136
Connection: close
Content-Type: text/plain; charset=UTF-8

This is the first time you're visiting this server
Server IP: 10.10.1.242
Client IP: 10.10.1.1
X-Forwarded-for: 10.220.135.22
Array
(
)
[root@CS-MS-1167580 ~]# curl -i http://10.220.166.226/session.php --cookie "PHPSESSID=pvlqa66cus9837vcvqgap9kjb5;escalation=10_10_1_242-80;"
HTTP/1.1 200 OK
Date: Wed, 09 Sep 2015 07:13:41 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 216
Connection: close
Content-Type: text/plain; charset=UTF-8

This is the first time you're visiting this server
Server IP: 10.10.1.89
Client IP: 10.10.1.1
X-Forwarded-for: 10.220.135.22
Array
(
    [PHPSESSID] => pvlqa66cus9837vcvqgap9kjb5
    [escalation] => 10_10_1_242-80
)
[root@CS-MS-1167580 ~]# curl -i http://10.220.166.226/session.php --cookie "PHPSESSID=pvlqa66cus9837vcvqgap9kjb5;escalation=10_10_1_242-80;"
HTTP/1.1 200 OK
Date: Wed, 09 Sep 2015 07:13:58 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 191
Connection: close
Content-Type: text/plain; charset=UTF-8

Your number of visits: 1
Server IP: 10.10.1.242
Client IP: 10.10.1.1
X-Forwarded-for: 10.220.135.22
Array
(
    [PHPSESSID] => pvlqa66cus9837vcvqgap9kjb5
    [escalation] => 10_10_1_242-80
)
[root@CS-MS-1167580 ~]# curl -i http://10.220.166.226/session.php --cookie "PHPSESSID=pvlqa66cus9837vcvqgap9kjb5;escalation=10_10_1_242-80;"
HTTP/1.1 200 OK
Date: Wed, 09 Sep 2015 07:14:01 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 190
Connection: close
Content-Type: text/plain; charset=UTF-8

Your number of visits: 1
Server IP: 10.10.1.89
Client IP: 10.10.1.1
X-Forwarded-for: 10.220.135.22
Array
(
    [PHPSESSID] => pvlqa66cus9837vcvqgap9kjb5
    [escalation] => 10_10_1_242-80
)
[root@CS-MS-1167580 ~]# curl -i http://10.220.166.226/session.php --cookie "PHPSESSID=pvlqa66cus9837vcvqgap9kjb5;escalation=10_10_1_242-80;"
HTTP/1.1 200 OK
Date: Wed, 09 Sep 2015 07:14:04 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 191
Connection: close
Content-Type: text/plain; charset=UTF-8

Your number of visits: 2
Server IP: 10.10.1.242
Client IP: 10.10.1.1
X-Forwarded-for: 10.220.135.22
Array
(
    [PHPSESSID] => pvlqa66cus9837vcvqgap9kjb5
    [escalation] => 10_10_1_242-80
)
[root@CS-MS-1167580 ~]# curl -i http://10.220.166.226/session.php --cookie "PHPSESSID=pvlqa66cus9837vcvqgap9kjb5;escalation=10_10_1_242-80;"
HTTP/1.1 200 OK
Date: Wed, 09 Sep 2015 07:14:05 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 190
Connection: close
Content-Type: text/plain; charset=UTF-8

Your number of visits: 2
Server IP: 10.10.1.89
Client IP: 10.10.1.1
X-Forwarded-for: 10.220.135.22
Array
(
    [PHPSESSID] => pvlqa66cus9837vcvqgap9kjb5
    [escalation] => 10_10_1_242-80
Be the first one to answer this question.