Analytic

Friday, August 29, 2008

Enable HTTPS in Debian

install this package:

apt-get install libapache-mod-ssl

Enable ssl mode in Apache:

a2enmod ssl

add port 443 in /etc/apache2/ports.conf:

Listen 443

Make certificate (after run this command you must answer some questions):

make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem

add these lines to
/etc/apache2/sites-available/YOURSERVER.COM.conf:

>VirtualHost *:443>

. . .
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
. . .

>/VirtualHost>

restart Apache2.

To redirect HTTP to HTTPS add these lines to
/etc/apache2/sites-available/YOURSERVER.COM.conf under 443 options:

RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R]
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 2

and restart Apache2 again!

No comments: