This is quick write up how to use single line for easy backend mapping within HAproxy. This has been showed to me by my buddy while challenging current configuration which started to grow.
The first thing you will need to have is to create a map file. Its structure its simple – first column is what comes is , second is what comes out. So for our domain mapping we can have file with domain name and respective backend i.e.
domain.com backend_com www.domain.com backend.com
Next is just configuration line on your front end associating domains with backends based on the host header
And that is it 🙂 you have now got your self really dynamic configuration