HAProxy, Set-Cookie and Cacheable Elements

From: John Marrett <JMarrett#mediagrif.com>
Date: Wed, 28 Apr 2010 11:46:30 -0400


I've noticed some interesting behaviour with persistance cookies and haproxy.

Let's say you use the following settings in your haproxy.cfg:

  cookie SERVERID insert indirect
  server static1 172.25.0.10:1080 cookie server1 check inter 15s   server static2 172.25.0.11:1080 cookie server2 check inter 15s

Any time haproxy receives a request that has no SERVERID cookie it will set one. Unfortunately, this doesn't take into consideration the cachability of the request. If a user receives a set-cookie in their response, on cacheable content, and if the proxy server isn't configured to strip Set-Cookie responses when serving from cache, all users of that proxy server will persist to a single backend server.

I noticed this while looking into some other issues we were having with Set-Cookie and proxy servers (notably the great firewall of Singapore).

Within our own application we either set Cache-Control: Private or ensure that we don't send a Set-Cookie on content that is declared as cacheable. I don't know if this kind of functionality could be interested for haproxy, but I thought I'd share my findings and see if anyone else was aware of this pattern of behaviour, if it was causing issues, and if there is or should be a way to address this issue.

-JohnF Received on 2010/04/28 17:46

This archive was generated by hypermail 2.2.0 : 2010/04/28 18:00 CEST