Install SSL with Certbot in Linux with Nginx

serverguy

SSL certificates are a popular way to secure web traffic, protecting sensitive information such as passwords, credit card details, and personal information by encrypting the traffic between a user’s web browser and a web server.

In this article, we will discuss how to install SSL with Certbot in Linux with Nginx, a popular open-source web server. Certbot is a free, open-source software tool that automates the process of obtaining and installing SSL certificates. Nginx is a high-performance, lightweight web server that is often used as a reverse proxy or load balancer.

Install Certbot

Certbot is available in the official repositories of most Linux distributions and can be installed using the package manager. You can install Certbot using the following command:

sudo apt install certbot python3-certbot-nginx

Configure Nginx

The next step that you will need to enable your Nginx’s server block by symlink. Here you can see how you can host your website with Nginx.

Obtain an SSL Certificate

Once you have configured Nginx, you can use Certbot to obtain an SSL certificate. Certbot supports various SSL certificate providers, including Let’s Encrypt, which provides free SSL certificates.

To obtain an SSL certificate using Certbot, use the following command:

sudo certbot --nginx -d testapi.serverguy.dev -d testapi.serverguy.dev

This command will run the Certbot utility and automatically configure Nginx to use SSL. Certbot will prompt you to enter your email address and agree to the terms of service. Certbot will then verify your domain name and request an SSL certificate from Let’s Encrypt. Once the SSL certificate is issued, Certbot will automatically configure Nginx to use SSL.

Renew the SSL Certificate

SSL certificates have a validity period of 90 days, after which they will expire and your website will no longer be secure. To avoid this, Certbot automatically renews SSL certificates before they expire, but you can also manually renew them using the following command.

sudo certbot renew --dry-run

Verify SSL Configuration

Now you can use online SSL checking tools such as SSL Checker or SSL Labs to ensure the SSL configuration is correct and your website is secure.

You can also check your Certbot’s status if anything goes wrong.

sudo systemctl status certbot.timer

In conclusion, SSL certificates are essential for securing web traffic and protecting sensitive information. Installing SSL with Certbot in Linux with Nginx is a straightforward process that can be completed within a few steps. By following the steps outlined in this article, you can easily secure your website and ensure that your users’ data is protected.

Fathi-Rahman

About the Author

Fathi Rahman

A junior DevOps engineer with a passion for learning and improving his skills. Previously worked as a customer engineer at Prothom Alo, where I developed a keen interest in server management, coding, and DevOps. In my free time, I enjoys writing articles, learning.

Tags

Category

Leave a Reply

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

Related Posts