Optional cookie persistence based on ACL (port)


I have a few situations where we have the same set of backend servers serving both stateful and stateless clients. The different clients use different frontend ports in HAProxy. Currently we have two different backends defined for the same set of servers - one with cookie persistence configured and one without. The clients are routed to the appropriate backend based on an ACL relating to the frontend port used in the request.

This all works, but I’m looking for a more elegant solution rather than having to define the backends twice (in reality I have 100’s of such backends to deal with). E.g. I was hoping that an ACL could be applied to the “cookie” directive, along the lines of:

cookie app_persistence_cookie insert if is_stateful_port_acl

but that doesn’t seem to work!

Any suggestions welcome! Thanks!

  • Adrian