How to Set Up SSL for Nginx using Letsencrypt in AWS 2021

In this tutorial, we will show you how to set up SSL for Nginx with Letsencrypt in Amazon Web Services (AWS). SSL is a protocol used to encrypt data between the server and the client. This ensures that any information transmitted over SSL connections cannot be shared or modified by third parties without knowledge of a secret key. SSL certificates are essential for securing your website, as well as ensuring your visitors can trust you with their personal information.

What is SSL and why should I care?

SSL stands for Secure Sockets Layer or SSL. SSL is a protocol that encrypts data traveling between the server and the client in order to prevent third parties from seeing sensitive information transmitted over an insecure connection such as standard unencrypted website traffic. SSL ensures you can trust your visitors with their personal information while they are on your site by protecting them against phishing sites that also try to steal this valuable information. A certificate is necessary for SSL connections so that both servers and browsers know what encryption method should be used when transmitting data back and forth

Setting up SSL for Nginx on AWS using Letsencrypt.

To get SSL enabled on your Nginx installation in AWS, you’ll want to use a third-party SSL certificate. Letsencrypt is an SSL provider that offers free SSL certificates for popular web servers such as Apache and Nginx. They also provide some of the best documentation available online so it will be easier than ever to get up and running with SSL on your site. If you haven’t already set up letsencrypt, follow these steps:

Steps:

To install SSL using Letsencrypt for your server, you need to install Certbot. To do that first enable EPEL.

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm


sudo yum-config-manager --enable epel

Once you enabled EPEL, you need to install Certbot for Nginx and issue the Certificate

sudo yum install certbot python2-certbot-nginx -y

Request and install SSL certificate

sudo certbot --nginx

To renew the Certificate automatically you need to set a cronjob via crontab. The commands are given below.



sudo crontab -e

After running this command, you will see a new blank screen for editing. Over there you need to give the commands which need to be executed and also time and free frequency.


0 3 * * * sudo certbot renew >/dev/null 2>&1

The command above will run this renewal command every day morning at 3 AM.

That’s it, you have successfully installed SSL and set up auto-renewal as well.

Conclusion

Thank you for reading this article on how to use Letsencrypt with Nginx in AWS. If you have any questions, please leave a comment below and we will get back to you as soon as possible!

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

This Post Has One Comment

Leave a Reply