I thought I had ssl set up correctly, but I discovered a problem.
This part is OK: ssldomain.com
goes to https://ssldomain.com
.
But this isn't working: www.ssldomain.com
is going to http://anotherdomain.com
, which happens to be the first vhost on the machine. In other words, I have a non-SSL vhost running on that server, and www.ssldomain.com
is bouncing to that one.
I used this utiltiy and verified that my Commodo "PositiveSSL" certificate covers the domain both with and without the "www".
I'm using Apache 2.2.3-65.
Here's my config in /etc/httpd/conf.d/ssl.conf
...
<VirtualHost *:443>
ServerName www.ssldomain.com
ServerAlias ssldomain.com
DocumentRoot "/opt/deployed_rails_apps/ssl_site/current/public"
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/www.ssldomain.com.crt
SSLCertificateKeyFile /etc/pki/tls/certs/www.ssldomain.com.pem
SSLCACertificateFile /etc/pki/tls/certs/www.ssldomain.com.ca-bundle
SSLHonorCipherOrder On
SSLCipherSuite ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH
SSLProtocol all -SSLv2
Header add Strict-Transport-Security "max-age=15768000"
ErrorLog "logs/ssldomain.com-ssl-error_log"
CustomLog "logs/ssldomain.com-ssl-access_log" common
CustomLog "logs/ssldomain.com-ssl-deflate_log" deflate
<Directory "/opt/deployed_rails_apps/rock_pebble/current/public">
Options -MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</Virtualhost>
# apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443 ssldomain.com (/etc/httpd/conf.d/ssl.conf:230)
*:80 is a NameVirtualHost
default server anotherdomain.com (/etc/httpd/conf/httpd.conf:232)
port 80 namevhost anotherdomain.com (/etc/httpd/conf/httpd.conf:232)
Syntax OK
You can't redirect at the DNS level, but you can easily configure another virtual host on port 80 to handle the redirects.
OK, thanks for the help, everyone. I think I have this figured out. I set up both a non-SSL vhost in httpd.conf and the SSL vhost as described in my question in ssl.conf.
The non-SSL vhost has this...
And the SSL vhost has only this...
Within my application code, I'm forcing all traffic to go to the corresponding
https
URL. Now the URL resolves both with and without the "www" and everything is served over SSL.