I am trying to set up haproxy to route to backends depending on the the subdomain that was used in the http request. Eg I have a regular web server running on port 8000 and an application server waiting for websocket connections running on port 8001 on the same IP adress. I now want that if the user hits app.mydomain.com:80 that he is redirected to port 8001 and if he hits www.mydomain.com (or any other subdomain) that he is redirected to the webserver on port 8000.
I came up with a plain configuration that I think should accomplish that (it is based loosly on this question):
frontend all 0.0.0.0:80 timeout client 86400000 acl aclMS1 hdr_dom(host) -i app use_backend beMS1 if aclMS1 default_backend beWEB backend beMS1 timeout server 86400000 server srvMS1 localhost:8001 maxconn 200 check backend beWEB server webserver localhost:8000 maxconn 200 check
However, it seems like this does not work. I always end up at my webserver on port 8000. What am I doing wrong?