title: HAProxy : Prevent stickiness to a backup server
body: <p>I'm facing a configuration issue with HAProxy (1.8).</p>
  
  <p>Context:</p>
  
  <ul>
  <li>In a HAProxy config, I have a several severs in a backend, and an additional backup server in case the other servers are down.</li>
  <li>Once a client gets an answer from a server, it must stick to this server for its next queries.</li>
  <li>For some good reasons, I can't use a cookie for this concern, and I had to use a stick-table instead.</li>
  </ul>
  
  <p>Problem:</p>
  
  <ul>
  <li>When every "normal" server is down, clients are redirected to the backup server, as expected.</li>
  <li>BUT the stick-table is then filled with an association between the client and the id of the backup server.</li>
  <li>AND when every "normal" server is back, the clients which are present in the stick table and associated with the id of the backup server will continue to get redirected to the backup server instead of the normal ones!</li>
  </ul>
  
  <p>This is really upsetting me... </p>
  
  <p>So my question is: how to prevent HAProxy to stick clients to a backup server in a backend?</p>
  
  <p>Please find below a configuration sample:</p>
  
  <pre><code>defaults
    option redispatch
  
  frontend fe_test
    bind 127.0.0.1:8081
    stick-table type ip size 1m expire 1h
    acl acl_test  hdr(host) -i whatever.domain.com
    ...
    use_backend be_test if acl_test
    ...
  
  backend be_test
    mode http
    balance roundrobin
    stick on hdr(X-Real-IP) table fe_test
    option httpchk GET /check
    server test-01 server-01.lan:8080 check
    server test-02 server-02.lan:8080 check
    server maintenance 127.0.0.1:8085 backup
  </code></pre>
  
  <p>(I've already tried to add a lower weight to the backup server, but it didn't solve this issue.)</p>
  
  <p>I read in the documentation that the "stick-on" keyword has some "if/unless" options, and maybe I can use it to write a condition based on the backend server names, but I have no clue about the syntax to use, or even if it is possible.</p>
  
  <p>Any idea is welcome!</p>