Hi Uri. Am 18.08.19 um 15:38 schrieb Uri Okrent: > Hi, I've set up haproxy in a docker swarm environment to balance > between several servers. The server task (let's call it foosrv) are > configured using docker's `replicate` directive to run on multiple > nodes, and as such, I don't have hostnames or IP addresses until > runtime. Luckily, the docker overlay network provides a handy DNS > record which facilitates finding my foosrv tasks. > > A DNS lookup of `tasks.foosrv` resolves to an array of IP addresses > for each of my replicated foosrv tasks. Seems like a perfect fit for > the server-template directive, and it is. The wrinkle is, I'm not > sure how exactly to use the params* in this scenario. According to the > documentation, `server-template` takes all the same params as > `server`. Some of those params though, require an argument which > would depend on the actual backend server. > > In my case, I need to configure sticky sessions using the cookie param > which requires you to pass a value. Based on reading the docs it > looks like it would look something like this: > > ``` > server-template srv 3 tasks.foosrv:80 check cookie foocookie insert > > # would be equivalent to: > server srv1 10.0.0.1:80 check cookie foocookie insert > server srv2 10.0.0.2:80 check cookie foocookie insert > server srv3 10.0.0.3:80 check cookie foocookie insert > ``` > > As you can see the entire group shares the same cookie value, which > doesn't work for my purposes as the replicas have no shared state. Is > there any ability to add some sort of template variable based on the > `num`? Some other way to accomplish what I need?
There is a open feature request on GH for this. https://github.com/haproxy/haproxy/issues/46 I don't know if anyone works on this, patches are welcome. Maybe you can up-vote to the feature to know how many people would also like to have this feature. > Thanks Best regards Aleks