Default page for removed SSL host

BillBuilt

Member
Mar 6, 2018
18
2
3
USA
cPanel Access Level
Root Administrator
Hello,

I have an interesting problem here. I had someone request to cancel their account, so I terminated their account. They must still have their DNS on their domain set to my server, so now if I go to their url via http:// I get the standard "If you are the owner of this website, please contact your hosting provider..." WHM page. HOWEVER, if I use https://, it will NOT show this page and tries to find the website, causing errors in the system since it does not exist. This domain was an auto-ssl host. Why would the https:// version NOT load the "If you are the owner of this website, please contact your hosting provider..." page as well?

Thanks in advance!
 

BillBuilt

Member
Mar 6, 2018
18
2
3
USA
cPanel Access Level
Root Administrator
Yes I had done that, but checked again just now in case I may have overlooked something before. There is no reference to the domain anywhere in httpd.conf. For now my only recourse is to check (from within PHP) whether or not the request is coming via HTTPS, and if so, redirect to the non-https url which then loads the standard not-found WHM page.
 

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
8,543
700
263
Houston
cPanel Access Level
DataCenter Provider
Hi @BillBuilt

Is loading the actual page or is it loading a page from a different site? The default behavior for Apache is to redirect https traffic for domains without an SSL VirtualHost to the first SSL VirtualHost in the configuration. Does the account in any form exist on the server still?

Thank you,
 

BillBuilt

Member
Mar 6, 2018
18
2
3
USA
cPanel Access Level
Root Administrator
The account does not exist any longer in any form. It was on a shared IP address however, so I am having to use the account that is being considered the default account for the IP address to do the redirect. Which after looking again, this particular account looks to indeed be the first SSL VirtualHost listed for that IP address. I have multiple shared IP addresses in use. So, this tells me that most likely their DNS on the domain at their registrar is still pointing to the IP address on my server, and since I am forcing HTTPS on all urls, any search engines, bookmarks, etc will be coming in on the HTTPS url to that IP address, and since the account does not exist, it's loading the first SSL VirtualHost it finds.

But, my question is, isn't it supposed to load the standard not-found WHM page regardless of HTTP or HTTPS? Is this a bug? Or is the workaround I described the only way to achieve this?

Thanks again!
 

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
8,543
700
263
Houston
cPanel Access Level
DataCenter Provider
Hi @BillBuilt

This is the default behavior since the implementation of SNI for Apache SSL VirtualHosts and not necessarily a bug, though I do think that it should be displaying a default page pending the configuration is default.

Does the hostname of the server resolve to the same IP and does the hostname have an SSL installed (or an SSL VirtualHost)
 

BillBuilt

Member
Mar 6, 2018
18
2
3
USA
cPanel Access Level
Root Administrator
>in this case the only way around this would be to add redirection for requests to that domain only

This is precisely what I am doing. HTTPS requests for that domain are getting redirected to the HTTP url for that domain and then it is displaying the "not found" WHM page.

Other terminated accounts were doing this as well so it isn't isolated to just this domain, but they appear to have stopped so I'm guessing they have reset their DNS settings at their registrar, and this domain will stop as well once they do the same.

Thanks! This has been a real head-scratcher for sure!
 

John C. Reid

Member
Feb 27, 2017
7
3
1
Redding, CA
cPanel Access Level
Root Administrator
Here is how I fixed this behavior:

I wanted something that would persist though different accounts being added and removed, and as such the default domain changing. I also wanted it to be generic enough that I could drop the same fix on all of my servers without having to modify anything that would be unique to each server. So I decided to create a ssl_vhost.local file in the /var/cpanel/templates/apache2_4/ folder. This would add my modification to every vhost. The condition is that if the requested domain is not a match for the vhost domain (including any subdomain possibility infinite subdomains deep) then rewrite the URI to the server's default page.

First I copied the ssl_vhost.default to ssl_vhost.local, and then I edited the new file. Just above the comment at the bottom of the file with reads

Code:
  # To customize this VirtualHost use an include file at the following location
  # Include "[% vhost_include_base %][% vhost.user %]/[% domain %]/*.conf"
I added the following:

Code:
    <IfModule rewrite_module>
        RewriteEngine On
        RewriteCond %{HTTP_HOST} !(.+\.)*[% wildcard_safe(vhost.servername) %]$ [NC]
        RewriteRule (.*) https://[% wildcard_safe(servername) %]/cgi-sys/defaultwebpage.cgi [R=301]
    </IfModule>
This uses the template language to ensure that the RewriteCond matches NOT the vhost domain or any conbination of subdomains, if that condition is met it will then rewrite to the server's hostname plus /cgi-sys/defaultwebpage.cgi with a permanent redirect.

Once this file is created I dropped it into the /var/cpanel/templates/apache2_4/ on each of my servers. Then on each server I rebuilt the Apache config and restarted Apache with with:

Code:
/usr/local/cpanel/scripts/rebuildhttpdconf
/usr/local/cpanel/scripts/restartsrv_httpd
I run LiteSpeed, so I also restarted LiteSpeed, although I don't know if it was strictly needed. So far the behavior works as expected and I have not had any issues.