Connection persistent

Hi,
i have a set up with 3 web server used as backend for HAProxy solution.
I have 1 server as primary and the other 2 as backup1 and backup 2.
If the primary goes down new connections are sent at backup 1 as we want to.
When the primary server comes up again all new connection are sent to him, once again as we want to, but the alredy exsisting one in the backup 1 are truncated.
Is there a way to let those existing connections one the backup1 server and once those are closed send all the traffic to the primary one?

Hi Riccardo,
a snippet of your configuration and HAproxy version would be usefull, but I believe you can achieve your goal using stick-tables and stick on in your backend section.

There’s a great example here:

# Learn SSL session ID from both request and response and create affinity.
backend https
    mode tcp
    balance roundrobin
    # maximum SSL session ID length is 32 bytes.
    stick-table type binary len 32 size 30k 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 s1 192.168.1.1:443
    server s2 192.168.1.1:443