Saturday, November 1, 2014

apache 2.2 - Is there a way to set up SSL for a domain and all subdomains?

So, I have a domain with many subdomains. Let's say example.com, a.example.com, b.example.com, c.example.com, etc.



I want to host them from the same server with the same IP address.



I have my wildcard certificate and my base domain certification, star_example_com.crt and example_com.crt.



I'm trying to set up my Apache server to support SSL on the domain and sub-domains, but can't seem to get it working. The domain is fine, but the sub-domains are not.



Here's my config:




NameVirtualHost *:443 # To support SNI, although, apparently, this directive is deprecated

SSLStrictSNIVHostCheck off


SSLEngine On
SSLCertificateFile /etc/apache2/ssl/example_com.crt
SSLCertificateKeyFile /etc/apache2/ssl/example_com.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown


DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined



Options Indexes FollowSymLinks MultiViews
AllowOverride All

Order allow,deny
allow from all





ServerAlias *.example.com
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/star_example_com.crt

SSLCertificateKeyFile /etc/apache2/ssl/star_example_com.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined




Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all




Am I missing something obvious here? All I want is to make sure that the right SSL cert is used for the domain and subdomains... everything is otherwise the same (this is a WordPress multisite, so it's all going to the same place in the end.




To be clear, I get an error when I access subdomains because I'm not getting the wildcard certificate.



To be further clear, I have over 80 subdomains. I'd like to avoid creating a VirtualHost for each one, if that's possible.



Any pointers?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...