I have a need for one of the VirtualHosts that WHM is pulling from cPanel when automatically building httpd.conf to be placed last, because it uses a wildcard subdomain. Example:
<VirtualHost XX.XX.XX.XX:80> ServerName app1.example.com ServerAlias *.app1.example.com </VirtualHost> <VirtualHost XX.XX.XX.XX:80> ServerName app2.example.com ServerAlias *.app2.example.com </VirtualHost> <VirtualHost XX.XX.XX.XX:80> ServerName example.com ServerAlias *.example.com </VirtualHost>
I'd like any request to foo.app1.example.com to go to the first VirtualHost, bar.app2.example.com to go to the second, etc. Any other request is handled by the main domain. bar.example.com or foo.example.com goes to the last VirtualHost.
This would all work just fine if the 3rd VirtualHost was listed last. However, because of how WHM is configured, whenever I run scripts that automatically build httpd.conf, they are re-ordered, the third VirtualHost block is placed first, and I lose the ability to contact app1.example.com or app2.example.com because *.example.com is a match first.
Any ideas on how to get WHM to respect the order I want? I looked into the perl script /usr/local/cpanel/bin/userdata_update as was recommended here:
...but couldn't make heads or tails of it. Perl isn't my strongest language.