A very crude yet functional HAProxy configuration to select a backend based on the first subdomain component.
global
daemon
defaults
mode http
frontend http
bind *:80
bind *:443 ssl crt /path/to/your/combined/certificate.pem
use_backend %[req.hdr(host),lower,word(1,.)]
# Used when it's 'subdomain.mydomain.tld'
backend subdomain
server default-server localhost:9001
# Used when it's 'anotherone.mydomain.tld'
backend anotherone
server default-server localhost:9002
# Used when it's 'onemore.sub.mydomain.tld'
backend onemore
server default-server localhost:9003