Remove Apache ServerAlias setting for mail.domain.tld?
Hi All
Reviewing the Apache configuration on a server WHM 70.x I noted that the httpd.conf file includes ServerAlias setting for "mail.clientdomain.tld" even when the DNS explicitly is set for remote mail and the "mail" host record is pointed to an external server / service IP address or cname.
My understanding is that Apache will never respond to that ServerAlias.
Looking at the Apache template:
/var/cpanel/templates/apache2_4/ssl_vhost.default
the values are populated from %vhost.serveralias_array variable and that I guess is populated from the account create process with a new account.
Is there a method to change the setup so that the "mail." entry is removed from the Apache config ?
Thanks
Tony
-
Hello Tony, First, you'll want to exclude the "mail" alias from the AutoSSL system using the SSL/TLS Status option in cPanel: mail as a serveralias entry at creation time for new domain names, then you'd need to follow the steps referenced on the following thread: Thank you. 0 -
Hello @jhawkins003, You could setup a script that makes use of the following UAPI function to exclude the "mail" alias from the AutoSSL feature: UAPI Functions - SSL::add_autossl_excluded_domains - Developer Documentation - cPanel Documentation Here's an example command to exclude a "mail" subdomain from AutoSSL: uapi --user=username SSL add_autossl_excluded_domains domains=mail.domain.tld
Once your script is developed, you can either run it regularly as part of a cron job, or configure it to run as a hook for the post stage of the following actions: Accounts::Create Cpanel::Api1::Park::park Cpanel::Api2::AddonDomain::addaddondomain You can read more about standardized hooks at: Guide to Standardized Hooks - Developer Documentation - cPanel Documentation This is the preferred method over modifying the Apache templates globally. Thank you.0 -
@cPanelMichael Thanks!! Thats a great solution. We we are deciding now whether to go the AutoSSL API route - or to deploy another script that trims the mail.domain.tld subdomain records from within /var/cpanel/userdata - perhaps via hook following account creation. Admittedly - our preference is to solve this problem as close to the core issue of the unnecessarily created mail.* subdomains as possible and not play whack a mole on other services if we don't have to. :D 0 -
Hi @jhawkins003, The API/Hook approach is a cleaner solution because the changes are fully supported. Modifying the contents of the userdata files is unsupported and thus could lead to problems down the road should something change in the way the userdata files are configured. Thank you. 0
Please sign in to leave a comment.
Comments
5 comments