Don't change Listen 80
to 443
in /etc/httpd/conf/httpd.conf
. SSL is configured in /etc/httpd/conf.d/ssl.conf
. On RHEL 6,SSL is enabled and listening by default with a self signed certificate.
You can get to the default site using SSL just by browsing to https://localhost
(you don't need to add the port to the end of the URL).
If you want to forward all HTTP requests to HTTPS (which is what I believe you are trying to achieve), you can either add a permanent redirect, or use the Apache module mod_rewrite
.
The easiest and most secure way is to set up a permanent redirect. Enable named virtual hosts and add a Redirect
directive to the VirtualHost in /etc/httpd/conf/httpd.conf
.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
Redirect permanent / https://localhost
</VirtualHost>
Using mod_rewrite
, you also create a named virtual host. This is not the recommended method, but will work.
NameVirtualHost *:80
<VirtualHost *:80>
# Enable the Rewrite engine
RewriteEngine On
# Make sure the connection is not already HTTPS
RewriteCond %{HTTPS} !=on
# This rewrites the URL and forwards to https
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
If you want to turn SSL off, comment out these lines in /etc/httpd/conf.d/ssl.conf
and restart Apache.
LoadModule ssl_module modules/mod_ssl.so
Listen 443