HTTPS stands for HyperText Transfer Protocol over SSL(Secure Socket Layer).It encrypts and decrypts user page requests as well as the pages that are returned by the Web server.
Steps for set up a web server and enabling https on it
1. Activate apache2 ssl module.
sudo a2enmod ssl
3.Apache ssl virtual host activation.
sudo a2ensite default-ssl
4.Restart the apache2 web server
sudo /etc/init.d/apache2 restart
5.Create a self-signed SSL certificate
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
The terminal look like this:
-----You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is what is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value,If you enter '.', the field will be left blank.----- Country Name (2 letter code) [AU]:In State or Province Name (full name) [Some-State]:kerala Locality Name (eg, city) []:kollam Organization Name (eg, company) [Internet Widgits Pty Ltd]:amrita Organizational Unit Name (eg, section) []:csn Common Name (e.g. server FQDN or YOUR name) []:mtech Email Address []:chindunair12@gmail.com
6.Set up the certificate
We need to set up the virtual hosts to display the new certificate.
6.1 Open up the SSL config file:
sudo nano /etc/apache2/sites-available/default
We need to make the following changes
Change the port on the virtual host to 443, the default SSL port:
<VirtualHost:*443>
Add a line with your server name right below the Server Admin email:
ServerName mtech:443
Add the following three lines to the virtual host configuration
SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Save and exit out of the file.
7.Activate new virtual host
sudo a2ensite default
8.Restart your apache server
sudo service apache2 reload
9.Checking for https activation.
Open the web browser and type localhost. You will be connected through secure http connection.
ie, It displays ” https://localhost” in the browser url space.
The certificate is look like this: