Backend server variables


I am trying to use haproxy as a transparent reverse proxy. I have ~50 sites where I would like to forward.
The request is structured as follow, where points to the haproxy server.
Once when the request is received the haproxy will transparently forward to website1/query.
I can apply ACLs with regex matching, but if I have website1,website2,website3,website4… I will need to have too many ACLs. My goal is to use the first part of the web request as a variable that could be used in the backend section.
Is this possible ?

Sure, whatever can be matched in a ACL at HTTP/TCP/IP level can be used for backend decisions.

Is it a good idea to change all URI’s in all your applications though? No, at least not for Internet facing websites. When you change the infrastructure, or when you just want to move one a website from one backend to another, all URIs change and the old ones become invalid.

ACLs are made for this purpose and there are people with hundreds of thousands of ACL entries. This is what haproxy does best. Moving this complexity to the user with an URI change is not a good idea in my opinion.

There will be a network restriction.

However I am not asking about the decisions - I am asking about dynamic backend servername.

Which I already responded above.