This is a follow up to my former question regarding the ability to do `src` based connection persistence / sticky tables subject to an additional rule for two (2x) query-strings where present:
1 - a targeted server instance (over-rules all else) 2 - user-id (used where present or is the only inclusion) EG (incoming) GET's: http://sub-domain.tld.org/ http://sub-domain.tld.org/?SID=6 http://sub-domain.tld.org/?SID=6&UID=123 http://sub-domain.tld.org/?UID=123 What I was striving to accomplish was the conventional `stick on src` based IP stick-tables where neither query-string is included. I believe that I've been able to achieve what was required using two (2x) separate backend with their own stick-tables. I'm including the configuration for future reference and in case anyone has any suggestion or alternative recommendations. ``` # # SID == server-id, # # UID == user-id, # # TLD == namespace / domain scope #//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ frontend inwebs_https bind *:80 bind *:443 #/*...*/ #//... acl url_TLD hdr(host) -i sub-domain.tld.org acl url_TID urlp(SID) -m found acl url_UID urlp(UID) -m found use_backend STICKY1 if url_TLD url_SID || url_UID use_backend STICKY2 if url_TLD ! url_SID ! url_UID #//=================================== #//... backend STICKY1 stick-table type ip size 1m stick on src balance leastconn server server1.tld.org 127.0.0.1:58810 check server server2.tld.org 127.0.0.1:58811 check server server3.tld.org 127.0.0.1:58812 check server server4.tld.org 127.0.0.1:58813 check #//-------------------------------- backend STICKY2 stick-table type string size 1m stick on src table STICKY1 stick on urlp(UID) balance leastconn use-server server1.tld.org if { urlp(SID) 1 } use-server server2.tld.org if { urlp(SID) 2 } use-server server3.tld.org if { urlp(SID) 3 } use-server server4.tld.org if { urlp(SID) 4 } server server1.tld.org 127.0.0.1:58810 check server server2.tld.org 127.0.0.1:58811 check server server3.tld.org 127.0.0.1:58812 check server server4.tld.org 127.0.0.1:58813 check #//-------------------------------- ``` Thanks very much & a big shout to the guys (bjozet, dlloyd, double-p, PiBa-NL, meineerde) on IRC: #haproxy @ freenode. On Tue, Feb 16, 2016 at 12:38 PM, Mehdi Ahmadi <[email protected]> wrote: > Hey guys a first & late joining to the list. > > I'd like to have a src / IP based sticky rule that uses one or two > combinations of query-string / get-parameters to determine stickiness. > > One (1x) query-string is specifically for session/user id's (UID) and the > second (2x) to allow for specific targeting of a server thats in the > concerned backend (SID). > > By default a leastconn balance algorithm should stick users to a server in > a Backend group where no UID or SID are specified. Where both UID & SID are > specified then the existing Stick entry should be overwritten with > precedence toward SID for the given UID and where only `UID` is specified > then any existing / prior entries should be used or the leasconn server > designated for the request. > > In short the idea is to stick and keep user to first assigned server > unless there are UID and or SID additions which should be respected > > I have the following two confs which I was experimenting toward a near > solution: > > #//-------------------------------- > #//- EXAMPLE 1 - leastconn > #//-------------------------------- > backend STICKY_HAP > stick-table type ip size 20k > stick on src > stick on urlp(UID) > balance leastconn > use-server S1.my.io if { urlp(SID) 1 } > use-server S2.my.io if { urlp(SID) 2 } > use-server S3.my.io if { urlp(SID) 3 } > server S1.my.io 127.0.0.1:58810 check > server S2.my.io 127.0.0.1:58811 check > server S3.my.io 127.0.0.1:58812 check > #//-------------------------------- > > #//-------------------------------- > #//- EXAMPLE 2 - url_param > #//-------------------------------- > backend STICKY_HAP > stick-table type string len 64 size 1m > stick on src > stick on urlp(UID) > balance url_param UID > use-server S1.my.io if { urlp(SID) 1 } > use-server S2.my.io if { urlp(SID) 2 } > use-server S3.my.io if { urlp(SID) 3 } > server S1.my.io 127.0.0.1:58810 check > server S2.my.io 127.0.0.1:58811 check > server S3.my.io 127.0.0.1:58812 check > #//-------------------------------- > > I've also tried other settings such as: > #//-------------------------------- > appsession UID len 64 timeout 3h request-learn query-string > appsession SID len 64 timeout 3h request-learn query-string > #//-------------------------------- > But without much luck. > > Thanks very much in advanced. >

