Using parts of uri to stick the request and a cookie to stick the response


Hi everyone!

Hi, I’m Fábio, a sysadmin, I hope I can learn from here, and, given enough time and debug, providing as well!

At the moment I’m a haproxy newbie trying to balance a quite peculiar web application.

That application provides services for editing simultaneously documents in a cluster configuration. Well, distinct users editing the same document will have to be served by the same server regarding that document, since internal pointers to edit actions in the document are not replicated along the cluster.

So, I can identify the document refered in the URI ( that is distinct between users since the uri contains distinct auth tokens ), and I can trace back based on the session cookie.

As I am a truly newbie I didn’t get yet how to extract with a regex the fileid from the uri.
The regex was ok, using it was not! Here my last attempt in haproxy.cfg backend session:

http-request set-var(req.stickvar) capture.req.uri /https\%3(.*)files\%2(\w)\w+[^%3|&]/

I wasn’t very luck in my googling, alternative syntax ou functions. Time to ask for help, the question is:

How can I use regex to fetch samples and store in a variable?

Because I want to achieve load balancing, sticking the request based on a portion of the uri.