title: HAproxy 1.5.8 How do I configure Cookie based stickiness?
body: <p>Our application requires cookie based sticky sessions, so we want to use HAproxy to balance incoming traffic towards a farm of IIS servers.</p>
  
  <p>We are using the following config which seems to work on the lab (round-robin working fine and session preserved), but fails when applied in producion with more that 3k concurrent users:</p>
  
  <p>frontend Front_http</p>
  
  <pre><code>bind :80
  mode http
  default_backend backend_http
  stats enable
  capture cookie ASP.NET_SessionId len 32
  maxconn 10000
  </code></pre>
  
  <p>frontend Front_https</p>
  
  <pre><code>mode http
  default_backend backend_https
  bind *:443 ssl crt /etc/haproxy/cert.pem 
  capture cookie ASP.NET_SessionId len 32
  maxconn 10000
  </code></pre>
  
  <p>backend backend_http</p>
  
  <pre><code> balance roundrobin
   option forwardfor
   stick-table type ip size 20k expire 5m
   appsession ASP.NET_SessionId len 64 timeout 5m request-learn prefix
   server Server_1 192.168.10.81:80 cookie Server_1
   server Server_2 192.168.10.81:80 cookie Server_2
   server Server_3 192.168.10.81:80 cookie Server_3
  </code></pre>
  
  <p>backend backend_https</p>
  
  <pre><code> balance roundrobin
   option forwardfor
   stick-table type ip size 20k expire 5m
   appsession ASP.NET_SessionId len 64 timeout 5m request-learn prefix
   server Server_1 192.168.10.81:80 cookie Server_1 ssl verify none
   server Server_2 192.168.10.81:80 cookie Server_2 ssl verify none
   server Server_3 192.168.10.81:80 cookie Server_3 ssl verify none
   http-request set-header X-Forwarded-Port %[dst_port]
   http-request add-header X-Forwarded-Proto https if { ssl_fc }
  </code></pre>
  
  <p>From the HAProxy 1.5.8 documentation I understand cookie based stickiness is achieved with command "appsession", but I don't understand the role other commands play, like "capture cookie" or "stick-table", are they necessary at all when using appsession? Can anyone help me understand how they work, and advise if you detect anything wrong with our config.</p>