Redirect trafic based on client domain used

I have a one arm haproxy with single IPv4 addderss as VIP.

  • clients browsing VIP:80 are forwarded to a real server 1
  • clients browsing VIP:81 are forwarded to a real server 2

What I would like to do is:

And from there the LB forwards the traffic to the appropriate real server.

Knowing that the DNS resolves both “server1.domain.com” and “server2.domain.com” to a single VIP address of the LB.

How can I perform this?
Any hint?