With cPanel 11, this has become very easy. Assuming that you have mod_proxy and mod_rewrite installed on your apache,
Go to WHM –> Tweak Settings –> Check the following settings
Add proxy VirtualHost to httpd.conf to automatically redirect unconfigured cpanel, webmail, webdisk and whm subdomains to the correct port (requires mod_rewrite and mod_proxy)
Automatically create cpanel, webmail, webdisk and whm proxy subdomain DNS entries for new accounts. When this is initially enabled it will add appropriate proxy subdomain DNS entries to all existing accounts. (Use /scripts/proxydomains to reconfigure the DNS entries manually)
Once enabled let the /scripts/proxydomains run and it will be enabled for all existing domains and new ones to be created. For a server with DNS cluster enabled, please refrain from enabling this, as it requires reload of those many zones of domains in the shared server at your DNS server.