Skip to content

How to Get Let's Encrypt SSL Certificate for Nginx with Certbot

DodaTech Updated 2026-06-24 2 min read

Let's Encrypt provides free SSL certificates through the automated Certbot tool. The Nginx plugin streamlines certificate issuance and installation. This guide walks through the specific troubleshooting steps to diagnose and resolve Let's Encrypt certificate issuance for Nginx.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

sudo certbot certonly --nginx -d example.com

Wrong: Using certonly which only gets the cert without configuring Nginx

sudo certbot --nginx -d example.com -d www.example.com --non-interactive --agree-tos --email admin@example.com

Right: Using --nginx plugin which gets and installs the cert

Output

Saving debug log to /var/log/letsencrypt/letsencrypt.log\nPlugins selected: Authenticator nginx, Installer nginx\nObtaining a new certificate\nPerforming the following challenges:\nhttp-01 challenge for example.com\nSuccessfully received certificate.

Prevention

To avoid future issues, follow these best practices:

  • Use --nginx plugin for automatic Nginx configuration whenever possible
  • Include both root domain and www subdomain with multiple -d flags
  • Run certbot renew --nginx regularly (via cron or systemd timer)
  • Test renewal with certbot renew --dry-run to verify configuration
  • Keep Nginx configuration files backed up before running certbot

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with certbot nginx

  1. Using foldl instead of foldl' causing stack overflow on large lists
  2. Forgetting deriving (Show, Eq) on custom data types needed for debugging
  3. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable

These mistakes appear frequently in real-world LETSENCRYPT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

Does certbot --nginx modify my existing Nginx configuration?|||Yes. The --nginx plugin automatically modifies Nginx server blocks to include SSL directives and certificate paths. It creates backup files before changes.
What ports must be open for certbot to work with Nginx? Port 80 (HTTP) must be open for the HTTP-01 challenge. If port 80 is blocked, use DNS-01 challenges with certbot --manual or a DNS plugin.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro