Я думаю, что cookie доступен только в режиме http, в режиме TCP вам нужно выполнить ssl affinity
Попробуйте это:
#maximum SSL session ID length is 32 bytes.
stick-table type binary len 32 size 20M expire 30m
acl clienthello req_ssl_hello_type 1
acl serverhello rep_ssl_hello_type 2
# use tcp content accepts to detects ssl client and server hello.
tcp-request inspect-delay 5s
tcp-request content accept if clienthello
# no timeout on response inspect delay by default.
tcp-response content accept if serverhello
# SSL session ID (SSLID) may be present on a client or server hello.
# Its length is coded on 1 byte at offset 43 and its value starts
# at offset 44.
# Match and learn on request if client hello.
stick on payload_lv(43,1) if clienthello
# Learn on response if server hello.
stick store-response payload_lv(43,1) if serverhello
server XXX:443 check
server YYY:443 check
option ssl-hello-chk
Для проверки включите статистику по сокетам и подключитесь2 браузера на сайте от haproxy:
stats socket /var/lib/haproxy/stats
bash#> echo "show table" | socat unix-connect:/var/lib/haproxy/stats stdio
# table: BACKEND_NAME, type: binary, size:20971520, used:2
bash#>echo "show table BACKEND_NAME" | socat unix-connect:/var/lib/haproxy/stats stdio
# table: BACKEND_NAME, type: binary, size:20971520, used:2
0x7f9ca0f24314:
key=8A3DF855010388A4DD94F71E0FEAF7A54A7032EA56D477D20F59B4F28CEF183B use=0
exp=1264499 server_id=1
0x7f9ca0f245c4:
key=C7EA05BA85730EAF725035EFB3C4F7537FCCCFD0469FB45A4A2DE85308ECF1C7 use=0
exp=1696667 server_id=2
Предупреждение, если у вас включен nbproc, сродство ограничено процессом.