Home/Engineer/Networking / Servers/Issuing a Free HTTPS SSL Cer…
Networking / ServersBeginnerubuntucentosdebiansslhttpsletsencrypt

Issuing a Free HTTPS SSL Certificate with Let's Encrypt

How to issue a free SSL certificate for your domain with Certbot, apply it to Nginx, and set up automatic renewal.

Contents
  1. Prerequisites
  2. Installing Certbot
  3. Issuing the Certificate
  4. Manual Nginx Configuration
  5. Automatic Renewal (90-day validity)
  6. Wildcard Certificate

Prerequisites

  • The domain's A record must point to the server IP
  • Ports 80 and 443 must be open

Installing Certbot

Bash
sudo apt install -y certbot python3-certbot-nginx

Issuing the Certificate

Bash
sudo certbot --nginx -d example.com -d www.example.com

Certbot automatically adds an SSL block and an HTTP → HTTPS redirect to your Nginx configuration.


Manual Nginx Configuration

Bash
sudo certbot certonly --nginx -d example.com
Nginx
server {
    listen 443 ssl http2;
    server_name example.com;

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

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
    ssl_prefer_server_ciphers off;
    ssl_session_cache shared:SSL:10m;
    ssl_stapling on;
    ssl_stapling_verify on;

    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}

Automatic Renewal (90-day validity)

Bash
systemctl status certbot.timer
sudo certbot renew --dry-run

Wildcard Certificate

Bash
sudo certbot certonly \
  --manual \
  --preferred-challenges dns \
  -d "*.example.com" \
  -d example.com
#ssl#https#letsencrypt#certbot#nginx#tls
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)NGINX documentation ↗OpenSSL documentation ↗

Questions & answers

Ask a question about this guide. We'll review and reply.