Direct several subdomains to a single backend with haproxy

To keep performance at a maximum (avoiding a regex every hit) but still cleaning up the config, I'd use an external file for your ACLs here. For example let's say you had a file called /etc/haproxy/sub1urls, which was exactly this:

apple.gamma.com
banana.gamma.com
cherry.gamma.com

Then in your config the ACL could simply be:

acl is_sub1 hdr(host) -i -f /etc/haproxy/sub1urls

Putting the other hosts in a sub2urls file the same way reduces your config down to:

frontend http-in
    bind *:80

    acl alpha     hdr(host) -i alpha.com
    acl beta      hdr(host) -i beta.com
    acl is_sub1   hdr(host) -i -f /etc/haproxy/sub1urls
    acl is_sub2   hdr(host) -i -f /etc/haproxy/sub2urls
    acl gamma     hdr(host) -i gamma.com

    use_backend a if alpha
    use_backend b if beta
    use_backend sub1 if is_sub1
    use_backend sub2 if is_sub2
    use_backend g if gamma

    default_backend default

This makes it very easy to maintain those other files, since they're just lists of hosts. It opens up the list of who can edit them and exposes less risk as well. For example, we have people editing these ACL lists like this in puppet who don't have to know the HAProxy config syntax at all.