To increase the security of your web applications, it is a standard process to enable HTTPS/SSL/TLS. Unfortunately, purchasing certificates can often be very expensive. Luckily, you can create a self-signed certificate for free for casual use or testing.
These steps are for Ubuntu, I wrote similar documentation for the Windows platform that you can find way back in my blog archives!
NOTE: As certificates generated in this manner are not verified by any recognized authority, many browsers will warn users (often in frightening language) about their insecurity. As stated above, these are best used only for internal use.
- First you will need to have apache2 installed, at a minimum you need to run:
sudo apt-get install apache2
- Enable the SSL module:
sudo a2enmod ssl
- Create the folder to store the keys and certificates:
sudo mkdir /etc/apache2/ssl
- Generate a private key and certificate:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
Enter reasonable values for the fields in question.
For FQDN Common Name enter *.domain.com for wildcard support! - Edit the config file:
sudo vi /etc/apache2/sites-available/default-ssl.conf
- Un-comment or update the following lines:
ServerName YOURDOMAIN.COM
ServerAlias WWW.YOURDOMAIN.COM
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
- Enable to SSL website and restart:
sudo a2ensite default-ssl.conf
sudo service apache2 reload
sudo service apache2 restart
- Test it out… provided your firewall routes port 443 to your server.
https://www.ssllabs.com/ssltest/analyze.html?d=YOURDOMAIN.COM
REFERENCES: