How to add Cookies on http request not on http response

Hi,

Can we add cookies on http request instead of http response like below:

backend app-backend
    mode http
    option httpclose
    balance leastconn
    cookie SERVERID insert indirect nocache
    server app1 10.89.1.10:80 check cookie app1 http-request add-header cookies SERVERID app1
    server app2 10.89.1.20:80 check cookie app2 http-request add-header cookies SERVERID app2

Or

Can we add in URL Parameter in request if SERVERID is not present in URL like below

backend app-backend
     mode http
     option httpclose
     balance leastconn
     cookie SERVERID insert indirect nocache
     server app1 10.89.1.10:80 check cookie app1 http-request set-uri https://%[req.hdr(Host)]%[path]?%[query]&SERVERID=app1 if SERVERID in URL NOT FOUND
     server app2 10.89.1.20:80 check cookie app2 http-request set-uri http://%[req.hdr(Host)]%[path]?%[query]&SERVERID=app2 if SERVERID in URL NOT FOUND

Yes, understand that this is unique requirement, Here is the use case. It difficult to explain but still I will try to explain:

  1. We have 2 application like manager and player

  2. Manager => We can’t put Manager application under load balancing because it is still using java memory for managing session, this memory is not shared. Development team require more time implement this

  3. Player => We plan to put Player application under load balancing. For authentication this player app send request to Manager application, if user is logged on Manager application then that user will be able to access player application. Multiple player applications which are under Load balancing can check user is authenticated by sending request to One Manager application. As there is only one Manager application then authentication should work fine, this was our expectation.

  4. Here is the twist: Player send authentication request to Manager application and after that request Manager application also send another request for that particular player, but player is load balanced, so it doesn’t know which was that player who has originally send the request for authentication. We plan to add SERVERID in cookies or in URL, so that we can send the authentication request to that particular Player application which is under load balancing using haproxy acl urlp_sub. Development team will handle rest of the things.

Note : This authentication requests are generated directly from server not from user browser and Player authentication happen on first request, so I need the details on first request not in response

Thanks

Can you elaborate what about your use case and why you need it? Sounds like you are misusing existing features.

I have modified the question and added the use case.

You can do this like this:

backend app-backend
mode http
http-request set-header Cookie SERVERID=12345678