Install apache2
# apt-get install apache2 openssl
Create self sign key
# mkdir -p /etc/ssl/localcerts
# openssl req -new -x509 -days 365 -nodes -out /etc/ssl/localcerts/apache.pem -keyout /etc/ssl/localcerts/apache.key
# chmod 600 /etc/ssl/localcerts/apache*
Edit Apache default SSL
# vi /etc/apache2/sites-available/default-ssl.conf
...
#SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateFile /etc/ssl/localcerts/apache.pem
#SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
SSLCertificateKeyFile /etc/ssl/localcerts/apache.key
...
Create link to enable default-ssl.conf
# ln -s /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/default-ssl.conf
Enabling Apacle SSL
# a2enmod ssl
Redirect all http request to https
# vi /etc/apache2/sites-available/000-default.conf
...
#DocumentRoot /var/www/html # we don't need root document
...
Redirect permanent / https://www.example.com # redirect all request can replace with ip address
...
Restart Apache2
# /etc/init.d/apache2 restart
References:
No comments:
Post a Comment