Mail Subdomain added as alias to main domain in httpd.conf

nslave

Member
Feb 27, 2017
5
0
1
Bulgaria
cPanel Access Level
Reseller Owner
Hi,
I have a issue that I cannot seem to understand how to resolve. There are multiple domains hosted on the server and some of them experience this strange behavior. From time to time (I think it is when the httpd rebuild itself) some subdomains on some domains start to load the main domain. When I open, lets say mail.example.com, the page that it is loaded is example.com. When I look at the httpd.conf I see that mail.example.com is listed as an alias for example.com. When I remove it the issue is resolved but I am interested in how to resolve it permanently, because every time the httpd is rebuilt the issue arises again. Every domain is a separate account if it matters.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
Hello,

This behavior is by-design as of cPanel version 60:

Change in mail. alias behavior for Apache server
The system now automatically creates an Apache server alias for the mail. subdomain for each domain, parked domain, and addon domain (but not subdomains). This allows the mail alias to appear in the same virtual host as the parent domain. We made this change in order to simplify Mail SNI and SSL certificate management and reduce unnecessary mail client warnings.

For example, Apache will now respond to mail.example.com as an alias for example.com. However, Apache will not automatically respond to mail.subdomain.example.com as an alias for the subdomain.example.com subdomains.
Thank you.
 

megahost

Member
PartnerNOC
Jun 10, 2012
11
0
51
cPanel Access Level
Root Administrator
Hi,

i get the same problem, mail.mydomain.com is showing the contect of mydomain.com and my SEO guy asked me to fix that.
Is there any way to fix that?

thanks.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
i get the same problem, mail.mydomain.com is showing the contect of mydomain.com and my SEO guy asked me to fix that.
Hello,

You can manual remove the "mail" entry from the "serveralias" line in the following configuration files under the /var/cpanel/userdata/$username directory:

/var/cpanel/userdata/$username/$domain.com
/var/cpanel/userdata/$username/$domain.com_SSL


Then, remove the .cache files for these domain names:

/var/cpanel/userdata/$username/$domain.com.cache
/var/cpanel/userdata/$username/$domain.com_SSL.cache


Next, rebuild the Apache configuration file:

Code:
/scripts/rebuildhttpdconf
However, keep in mind this is part of what allows SSL certificate validation for mail.domain.tld as part of the Domain TLS functionality:

What is Domain TLS - cPanel Knowledge Base - cPanel Documentation

Thank you.
 

4u123

Well-Known Member
PartnerNOC
Jan 2, 2006
933
21
168
This is causing a problem with the mail subdomain showing up in search engine results, even though the mail subdomain has never been linked to from anywhere.

I'm sorry guys, but a subdomain that is not used for web content has no right being included in the Apache configuration, especially when it is a CNAME. This can cause all sorts of problems with SEO.

We need an option to disable this in tweak settings please. ASAP

You said...

We made this change in order to simplify Mail SNI and SSL certificate management and reduce unnecessary mail client warnings.

There are no "unnecessary" mail client warnings. Those warnings are legitimate This functionality is outdated anyway. Why use the mail subdomain at all when the main domain is already configured and will most likely be covered by an SSL cert anyway?

Moving forward, you should be looking at dropping the mail and FTP subdomains completely, rather than trying to find a workaround that is impractical and could cause damage.

This is completely unwanted and unnecessary.
 
  • Like
Reactions: MaxFein

TAugustine

Registered
May 26, 2020
1
0
1
Noida, India
cPanel Access Level
Website Owner
Hello Support,

I am also facing the similar issue, mail.mydomain.com is showing the exact same contents of mydomain.com

This is a big-time issue as google search console is flagging all the pages as duplicate content 'Duplicate without user-selected canonical'

Kindly advice as a website owner how can I fix this? Should the workaround provided by you to be done by the hosting provider?

Thanks in Advance.
 

Attachments

4u123

Well-Known Member
PartnerNOC
Jan 2, 2006
933
21
168
This has come up again with a customer today - they are really not happy about it. I honestly don't know what you guys were thinking with this.

At the very least you need to globally change the DNS records for the mail subdomain to an A record instead of a CNAME so it can have its own separate vhost entry and point it to some default page instead! It has to be done.

Come on guys pull your socks up! It's painful to see this kind of thing happening.
 

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
103
27
78
Greece
cPanel Access Level
DataCenter Provider
Had a customer complain about it today too. His WordPress site would show up under domain.com / www.domain.com / mail.domain.com
Had to create an .htaccess rule to redirect mail. requests to www.

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mail.domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R,L]
I didn't redirect to https to avoid breaking AutoSSL for mail.domain.com, but maybe I'll need to add the Comodo / .well-known exceptions too.
 

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
103
27
78
Greece
cPanel Access Level
DataCenter Provider
I understand this was added to be able to create SSL certificates for the mail. subdomain for use with Exim and Dovecot.
I don't want this to stop working, as offering the customer to use mail.their_domain.com as incoming/outgoing mailserver with SSL if very convenient, but maybe there could be a rule in the httpd.conf level that will only allow traffic for DVC to pass through to public_html/.well-known/... and either block anything else, or redirect it to the root domain.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
2,920
372
213
cPanel Access Level
Root Administrator
I spoke with several different people about this issue and there currently aren't plans to change this behavior. The best thing to do for this would be to open a feature request as any change mentioned in this thread so far would require significant changes to the system.