How to Install SSL Certificate on AWS EC2 with Ubuntu NGINX

How to Install SSL Certificate on AWS EC2 with Ubuntu NGINX

To secure your site or server with HTTPS, for this, you have to install Let’s Encrypt, then set up the free SSL certificate for your site or server on your AWS EC2 instance with Ubuntu Nginx server.

To enable HTTPS on aws ec2 instance with Ubuntu NGINX server, Just use sudo apt install certbot python3-certbot-nginx to install Letsencrypt and then use the sudo certbot --nginx -d yourdomain.com -d subdomain.yourdomain.com command to set up free SSL/TLS certificate for your server or site.

How to Install and Setup Free SSL Certificate with Let’s Encrypt on AWS EC2 Instance Ubuntu NGINX

Here are some steps to install and set up free SSL certificate with let’s Encrypt on AWS ec2 instance ubuntu NGINX server:

Step 1 – Connect to AWS Instance via SSH OR Putty

To connect Amazon AWS EC2 instance via putty SSH.

If you do not how to connect AWS EC2 instance via SSH, Read this => Connect AWS EC2 instance via ssh for Windows, Mac, and Linux users.

Step 2 – Update System Packages

To update the system’s packages, you need to use the sudo apt update command on a terminal window:

sudo apt update

Step 3 – Install Nginx

To install Nginx on aws ec2 ubuntu server, simply type sudo apt install nginx command on the aws ssh terminal window and press Enter:

sudo apt install nginx

Once it is installed, To start and enable NGINX server on aws ec2 instance using sudo systemctl start nginx && sudo systemctl enable nginx command on ssh terminal window:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 4 – Install Let’s Encrypt Certbot

To install Let’s Encrypt Certbot by using sudo apt install certbot python3-certbot-nginx command on ssh terminal window to get HTTPS on AWS EC2 NGINX server:

sudo apt install certbot python3-certbot-nginx

Step 5 – Get and Set Up New Free SSL/TLS Certificate

To get and set up a free SSL certificate with let’s encryption on aws ec2 nginx ubuntu server, simply type sudo certbot –nginx -d yourdomain.com -d subdomain.yourdomain.com command on ssh terminal windows:

sudo certbot --nginx -d yourdomain.com -d subdomain.yourdomain.com

Step 6 – Configure NGINX Server to Activate SSL

To activate the free SSL certificate, you need to open default configuration, which you can do by typing the sudo nano /etc/nginx/sites-available/default command in an AWS Terminal window:

sudo nano /etc/nginx/sites-available/default

Once the default conf file is opened on SSH window, Add the following code in the default configuration file to activate the free SSL certificate:

server {
    listen 443 ssl;
    server_name yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

    location / {
        # Your Nginx configuration goes here
    }
}   

Step 6 – Restart NGINX Server

The best practice to check Nginx configuration for any syntax errors before restart server using the following command:

sudo nginx -t

Finally, restart nginx server:

sudo systemctl restart nginx

You have installed and setup the free SSL certificate for yourdomain.com. Now your yourdomain.com will run on HTTPS.

Conclusion

Through this tutorial, you have learned how to install Let’s Encrypt on aws ec2 instance with Nginx Ubuntu and set up a free SSL certificate to enable HTTPS on a site or server.

Recommended Linux Ubuntu Tutorials

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *