0

Objective: To have multiple sub-domains working successfully with a wildcard SSL certificate. The sub domains do not have separate dedicated cpanel account, and hence share the same dedicated IP address(for the main domain) for the SSL.

Current scenario: We got a wildcard SSL and installed it on VPS. We have two subdmains next.my-personal-website.com and wp.my-personal-website.com. Earlier there was not virtualhost entry for port 443 for any sub domains. All https request to subdomain were being served from the corresponding url of the main domain.

After we edited the httpd.conf file and added the virtualhost entry for port 443 for next.my-personal-website.com, all https requests to the main domain and the wp.my-personal-website.com started getting served from the next.my-personal-website.com

We are on a Linux VPS. Cpanel 11.30.6 , Apache 2.2.22, PHP 5.3.13

We tried to follow this tutorial , but it seems it did not work.

Virtualhost entries:

<VirtualHost xx.xx.144.72:443>
    ServerName next.my-personal-website.com
    ServerAlias www.next.my-personal-website.com
    DocumentRoot /home/myguardi/public_html/next.my-personal-website.com
    ServerAdmin webmaster@my-personal-website.com
    UseCanonicalName On
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com combined
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User myguardi # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup myguardi myguardi
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup myguardi myguardi
    </IfModule>
    ScriptAlias /cgi-bin/ /home/myguardi/public_html/next.my-personal-website.com/cgi-bin/
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
    SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
    SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
    CustomLog /usr/local/apache/domlogs/next.my-personal-website.com-ssl_log combined
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/myguardi/public_html/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/ssl/2/myguardi/my-personal-website.com/*.conf"

</VirtualHost>


<VirtualHost xx.xx.144.72:443>
    ServerName my-personal-website.com
    ServerAlias www.my-personal-website.com
    DocumentRoot /home/myguardi/public_html
    ServerAdmin webmaster@my-personal-website.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/my-personal-website.com combined
    CustomLog /usr/local/apache/domlogs/my-personal-website.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User myguardi # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
        suPHP_UserGroup myguardi myguardi
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        SuexecUserGroup myguardi myguardi
    </IfModule>
    ScriptAlias /cgi-bin/ /home/myguardi/public_html/cgi-bin/
    SSLEngine on

    SSLCertificateFile /etc/ssl/certs/my-personal-website.com.crt
    SSLCertificateKeyFile /etc/ssl/private/my-personal-website.com.key
    SSLCACertificateFile /etc/ssl/certs/my-personal-website.com.cabundle
    CustomLog /usr/local/apache/domlogs/my-personal-website.com-ssl_log combined
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    <Directory "/home/myguardi/public_html/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>

    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/ssl/2/myguardi/my-personal-website.com/*.conf"

</VirtualHost>

in the same order as in httpd.conf. Any help on how to get this working correctly is greatly appreciated.

Thank you.

MadHatter
  • 79,770
  • 20
  • 184
  • 232
Amitabh
  • 103
  • 5
  • 1
    Where is your NameVirtualHost xx.xx.144.72:443 directive? – HTTP500 Nov 12 '12 at 16:07
  • @HTTP500, Gosh! its not there. Checked and confirmed. Will edit the httpd.conf and add it. Will get back with result after edit and apache restart. – Amitabh Nov 12 '12 at 16:35
  • @Amitabh note your setup will not work on older browsers - see [this article](http://en.gentoo-wiki.com/wiki/Apache2/SSL_and_Name_Based_Virtual_Hosts) – Kamil Šrot Nov 12 '12 at 19:12
  • It worked. Perfectly. I will I could mark this answer as correct :) – Amitabh Nov 13 '12 at 18:18

1 Answers1

3

You need to include the NameVirtualHost xx.xx.144.72:443 directive.

HTTP500
  • 4,833
  • 4
  • 23
  • 31