Monday, January 15, 2018



Recently I configured SSL on Amazon EC2 instance running Apache server. In this blog I am going to explain the procedure step by step.

Step 1 : Generate CSR and submit to CA authority for verification

To generate CSR login to your server with SSH and use following command.

openssl req -new -newkey rsa:2048 -nodes -keyout YourDomain.key -out YourDomain.csr

Once you execute this command it will ask for certain inputs and based on it it will generate csr file. That you have to submit to CA authority and generate

Step 2 : Edit Inbound rules on your EC2 Instance and allow HTTPS

Login to Amazon AWS console and go to EC2 dashboard. Click on instance and edit security rules. Select HTTPs and allow it from anywhere.

Step 3 : Upload your SSL certificate and key file to EC2 using SSH

 You can use SCP command to upload crt file and pem key file to server.

scp -i "YourKey.pem" "Cert.crt" ubuntu@YourIP:/home/ubuntu/Cert.crt
scp -i "YourKey.pem" "Key.key" ubuntu@YourIP:/home/ubuntu/Key.key

Step 4 : Edit Default SSL config file and Add Certificate In File

Go to  cd /etc/apache2/sites-available

Update default-ssl.conf file by using command

sudo nano default-ssl.conf

Add following lines in file

SSLEngine on
SSLCertificateFile      /home/ubuntu/Cert.crt
SSLCertificateKeyFile /home/ubuntu/Key.key

Save the file.

Step 5 : Enable SSL mode in Apache and set config file to default-ssl.conf

Now we have ssl config file set, we have to enable SSL mode in apache and set config file.

Use following command

sudo a2enmod ssl
sudo a2ensite default-ssl.conf
sudo service apache2 reload
sudo service apache2 restart

That's it and now you can access your web app on HTTPS. Hope this helps you.

No comments:

Post a Comment