Secure Nginx with Let’s Encrypt

Search for a command to run...

No comments yet. Be the first to comment.
When storing sensitive data in Amazon S3, it's critical to make sure it's protected. AWS provides multiple encryption options, and one of the most secure and flexible methods is server-side encryption with AWS Key Management Service (SSE-KMS) using a...

Hi!👋 I'm excited to share how I set up OpenStack using DevStack on local machine. If you’re just getting started with OpenStack, this guide might help you spin up your own testing environment. ⚠️ Disclaimer: This is a minimal, all-in-one installati...

Whether you're a student, developer, or DevOps engineer preparing for a demo, this guide walks you through setting up AKS for demo purposes quickly and efficiently. Let’s get started! Prerequisites An Azure Account: Sign up here Azure CLI: Install ...

Monitoring your infrastructure doesn’t have to be complicated. In this guide, I’ll show you how to set up Prometheus and Grafana in the easy way. Whether you're a beginner or just looking for a quick demo environment, this setup will get you up and r...

If you're running a website or app, securing it with HTTPS is a must. Not only does HTTPS protect your users’ data with encryption, but it also improves trust and even your site's SEO ranking.
Let’s Encrypt is a free and trusted Certificate Authority (CA) that provides SSL/TLS certificates. Using their service with Certbot (the official tool for managing certificates) makes SSL setup almost effortless - especially when paired with Nginx.
Here’s what I had set up before starting:
A VM running Ubuntu 22.04 on Azure
Nginx installed and running
Ports 80 (HTTP) and 443 (HTTPS) open
A domain name with an A record pointing to the VM’s public IP
This ensures that your domain resolves to your server and that Let's Encrypt can validate domain ownership.





First, install Certbot and its Nginx integration plugin:
sudo apt install certbot python3-certbot-nginx

Open your site’s Nginx config:
sudo vi /etc/nginx/sites-available/example.com
In the server block, make sure to add:
server_name example.com;
Nginx needs to know which domain this block is for. This is how Certbot identifies which site to secure.


Check for any syntax errors:
sudo nginx -t
Apply your changes:
sudo systemctl reload nginx

Now, let’s request the SSL certificate and configure Nginx in one command:
sudo certbot --nginx -d example.com
If this is your first time running certbot, you will be prompted to enter an email address and agree to the terms of service.
This command will:
Verify your domain ownership
Download and install the SSL certificate
Automatically configure your Nginx site for HTTPS

Certbot sets up an automatic renewal timer. Verify that it's running:
sudo systemctl status certbot.timer
Let’s Encrypt certificates expire every 90 days, so automated renewal is critical.
Test Renewal
Do a dry-run of the renewal process to ensure it's working:
sudo certbot renew --dry-run
This makes sure your renewal process will succeed before it really matters.


Securing your website or app with HTTPS is essential for encrypting user data, enhancing trust, and boosting SEO. Let’s Encrypt offers free SSL/TLS certificates via Certbot, simplifying setup with Nginx. The step-by-step guide includes installing Certbot and the Nginx plugin, editing the Nginx server block with your domain, and using Certbot to obtain and install an SSL certificate. Automated renewal ensures certificates stay valid, with verification and renewal testing processes included.