Step-by-Step Guide to Activate SSL with Certbot in NGINX

Chinmay Roy
2 min readJun 14, 2024

To activate SSL effectively and easily for your Nginx server, you can use Certbot, a free tool that helps automate the process of obtaining and renewing SSL/TLS certificates from Let’s Encrypt. Here’s a step-by-step guide to do so:

1. Install Certbot

First, you need to install Certbot and the Nginx plugin. You can do this using your package manager. For example, on Ubuntu, you can use:

sudo apt update
sudo apt install certbot python3-certbot-nginx

2. Obtain SSL Certificate

Use Certbot to automatically obtain and install an SSL certificate for your domain. Replace website_name with your actual domain name.

sudo certbot --nginx -d website_name

Certbot will prompt you through the process, which includes verifying your domain ownership and automatically configuring your Nginx server to use the new certificate.
3. Configure Nginx for SSL

Certbot should automatically update your Nginx configuration. However, to ensure everything is set up correctly, your Nginx configuration file should look something like this:

server {
if ($host = website_name) {
return 301 https://$host$request_uri;
}

listen 80;
server_name website_name;
return 404;

}
server {
listen 443 ssl;
server_name website_name;

ssl_certificate…

--

--