-1

Hi I'm having major problems with a server, SSL works perfectly when connecting with https://..., I need to set up redirection from http to https.

This is my ssl.conf, CentOS-6, with one IP address. SSL cert set up with SANs. Would rather not use .htaccess.

Listen 172.21.11.48:443

NameVirtualHost 172.21.11.48:443

LoadModule ssl_module   modules/mod_ssl.so
SSLEngine on
SSLSessionCache         shmcb:/var/cache/httpd/mod_ssl/ssl_scache(512000)

<VirtualHost 172.21.11.48:443>
SSLEngine on
ServerAlias      "webmail.example.com"
DocumentRoot    "/var/www/html/roundcubemail"
SSLCertificateFile /etc/pki/tls/certs/aether.example.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/aether.example.com-2048.key
SSLCACertificateFile /etc/pki/tls/certs/exampleca.crt
</VirtualHost>

<VirtualHost 172.21.11.48:443>
SSLEngine on
ServerAlias      "cloud.example.com"
DocumentRoot    "/var/www/html/owncloud"
SSLCertificateFile /etc/pki/tls/certs/aether.example.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/aether.example.com-2048.key
SSLCACertificateFile /etc/pki/tls/certs/exampleca.crt
</VirtualHost>

When connecting on http://webmail.example.com it errors with:

Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port

When I add another vhost on port 80, Apache fails to start. Any help would be gratefully received.

1
  • Did you search for how to do this? At all? Even a little bitty redirect non-SSL to SSL in apache on Google?
    – voretaq7
    Sep 25, 2013 at 21:35

1 Answer 1

0

You just need to edit your httpd.conf file or the file where your virtual host is specified and add these lines to redirect http to https:

  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
2
  • Hi Abhishek, thankyou for replying - where in httpd.conf should it go? Do I have to create another Vhost. My vhosts are in ssl.conf - can your lines of code just go in there?
    – Steve
    Sep 25, 2013 at 19:16
  • Hi Abhishek you are as star, thankyou so much for the tip - all working fine now.
    – Steve
    Sep 26, 2013 at 9:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .