Wildcard SSL installation - ssl subdomain shows main domain

theallan

Active Member
Nov 17, 2005
36
2
158
Hello all,

I'm having some problems installing a wildcard SSL certificate in WHM (11.34). I've got an account which has a detected IP, and it has a domain and sub-domains on it. I'd like those sub-domains all to be able to use ssl (the whole point of the wildcard certificate :) ).

I've got the certificate installed after having read a load of other threads, by creating a sub-domain called `*` and then installing the wildcard certificate. Now I get the following behaviour:

http://domain.com - Main site loads
https://domain.com - Main site loads
http://sub.domain.com - Sub-domain site loads
https://sub.domain.com - Main site loads

The problem being the last part. From what I've read in other posts I need to do some editing of the configuration files or something, and I've tried the suggestions there, but with no success.

Can anyone point me in the right direction?

Allan
 

elialum

Active Member
Sep 10, 2008
29
1
53
Israel
cPanel Access Level
DataCenter Provider
Hi,

Please try the following -

  • Reinstall the SSL certificate (if necessary) for *.domain.com as normal in cPanel, using the wildcard cert. Treat it like a normal certificate. That is, enter "domain.com" and not "*.domain.com", and the username USERNAME instead of "nobody".
  • In /var/cpanel/userdata/USER/ copy the example.com_SSL file to $subdomain.DOMAIN.COM_SSL for each subdomain.
  • In each copied file, edit the following variables to match the non-SSL subdomain: documentroot, servername, serveraliases
  • Rebuild the Apache configuration with /scripts/rebuildhttpdconf
  • Restart the Apache server with /scripts/restartsrv_httpd

An alternative to the above would be to instead setup those subdomains as their very own unique cPanel user accounts with their own unique dedicated IPs. You could then simply install the cert to each unique cPanel account and accomplish the same behavior. This alternative method would be entirely through cPanel/WHM supported methods.
 

theallan

Active Member
Nov 17, 2005
36
2
158
@elialum - this is absolutely superb. Thanks very much for the clear and concise instructions. It worked perfectly for me :)

Allan
 

Dave Smith

Active Member
Mar 20, 2016
44
12
8
Lisbon
cPanel Access Level
Root Administrator
We just had the same issue and stumbled upon this thread. We found an alternative solution, below:

1) Create the required subdomain and its directory under CPANEL and update DNS to reflect (point to) the new subdomain.

2) Generate your SSL certificate with Lets Encrypt (or buy an SSL certificate for all your domains which is silly) including the Subdomains you wish to operate.

Code:
./letsencrypt-auto certonly --text --agree-tos --email [email protected]:COM -d CHANGEME:COM -d www.CHANGEME:COM -d subdomain.CHANGEME:COM --break-my-certs
3) Install the SSL certificate under CPANEL to your respective primary domain by dropping down the select list and picking it. Then paste the required details in to their respective areas, Private Key, Chain, Cert. Then click Install at the bottom.

4) Do the same as step 3 but select your subdomain from the select list.

Job done!

We hope this helps somebody else with the same problem we were having, ie, the new SSL subdomain was directing to the default page for the web root and not the page contained within the subdomain directory itself.
 
  • Like
Reactions: trec-r