Question

I have a CentOS/Apache+OpenSSL server. I host two domain names with wildcard sub domains (application logic surfaces the correct site), e.g.

https://*.testing1.com

https://*.testing2.com

It works great over HTTP:-

   <VirtualHost *:80>
  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin webmaster@testing1.com
  ServerName  testing1.com
  ServerName  testing2.com

  ServerAlias *.testing1.com *.testing2.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /home/app/public_html/public

</VirtualHost>

I've purchased two Wildcard SSL certificated for both testing1.com and testing2.com, but I'm unsure how to set it up in this structure:-

    <VirtualHost *.testing1.com:443>
     SSLEngine On
     SSLCertificateFile /etc/httpd/ssl/*.testing1.com.crt
     SSLCertificateKeyFile /etc/httpd/ssl/*.testing1.com.key
     SSLCACertificateFile /etc/httpd/ssl/geotrust.cer

     ServerAdmin john@testing1.com
     ServerName testing1.com
     ServerAlias *.testing1.com

        DirectoryIndex index.html index.php
        DocumentRoot /home/app/public_html/public

  </VirtualHost>

   <VirtualHost *.testing2.com:443>
     SSLEngine On
     SSLCertificateFile /etc/httpd/ssl/*.testing2.com.crt
     SSLCertificateKeyFile /etc/httpd/ssl/*.testing2.com.key
     SSLCACertificateFile /etc/httpd/ssl/geotrust.cer

     ServerAdmin john@testing2.com
     ServerName testing2.com
     ServerAlias *.testing2.com

        DirectoryIndex index.html index.php
        DocumentRoot /home/app/public_html/public

  </VirtualHost>

The above for the SSL doesn't work, with the *.testing1.com definition, nor with just testing1.com.

I will also need to repeat this for testing2.com

Was it helpful?

Solution

Name-based virtualhosts and SSL wil only work if all the virtualhosts are within the same domain and you have a wildcard SSL certificate for that domain.

But you have 2 different domains.

In this case it will only work if you give each SSL-enabled virtualhost it's own IPaddress. So you should use IP-based virtualhosts, not Name-based.

Explanation: The ServerName which is requested, is contained in the HTTP request headers, but before that the SSL encryption must be already setup. So the ServerName is only available after the encryption has been setup. Therefore Apache can never know which SSL certificate te serve up and wil just use the first one available on that particular IPaddress.

OTHER TIPS

With the single dedicated IP we can configure domain-based wildcard SSL in centos + apache2.2 server.

Hope the configurations below will help you guys!!

NameVirtualHost IP:80
NameVirtualHost IP:443

Domain 1

<VirtualHost IP:80>
        ServerName      abc.domain1.com
        DocumentRoot    /var/www/html/domain1
</VirtualHost>
<VirtualHost IP:443>
        ServerName      *.domain1.com
        DocumentRoot    /var/www/html/domain1
        SSLEngine       On
        SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
        SSLCertificateFile      /var/www/html/domain1/cert/5465456.crt
        SSLCertificateKeyFile   /var/www/html/domain1/cert/domain1.com.key
        SSLCertificateChainFile /var/www/html/domain1/cert/g2-g1.crt
</VirtualHost>

Domain 2

<VirtualHost IP:80>
        ServerName      abc.domain2.com
        DocumentRoot    /var/www/html/domain2
</VirtualHost>
<VirtualHost IP:443>
        ServerName      abc.domain2.com
        DocumentRoot    /var/www/html/domain2
        SSLEngine       On
        SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
        SSLCertificateFile      /var/www/html/domain2/cert/5465456.crt
        SSLCertificateKeyFile   /var/www/html/domain2/cert/domain1.com.key
        SSLCertificateChainFile /var/www/html/domain2/cert/g2-g1.crt
</VirtualHost>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top