Example: Certbot with NGINX using HTTP-01 Domain Validation

This guide provides a complete example of using Certbot with NGINX to obtain and install a certificate using HTTP-01 domain validation.


Prerequisites

  • ACME Directory URL created
  • NGINX installed and running
  • Certbot installed
  • Domain name pointing to your server
  • Port 80 open and accessible
  • Root or sudo access to the server

Step 1: Install Certbot NGINX Plugin

sudo apt install python3-certbot-nginx

Step 2: Configure NGINX for HTTP-01 Validation

Certbot will automatically configure NGINX for HTTP-01 validation, but you need to ensure your NGINX configuration includes the server block for your domain:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location / {
        root /var/www/html;
        index index.html;
    }
}

Step 3: Run Certbot with NGINX Plugin

sudo certbot --nginx \
    --server https://one.digicert.com/mpki/api/v1/acme/v2/directory \
    --eab-kid YOUR_EAB_KEY_ID \
    --eab-hmac-key YOUR_EAB_HMAC_KEY \
    -d yourdomain.com \
    -d www.yourdomain.com

Note: Replace YOUR_EAB_KEY_ID, YOUR_EAB_HMAC_KEY, and yourdomain.com with your actual values.

🖥️ Sample Terminal Output:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Registering without email!

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for yourdomain.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/yourdomain.com

Successfully received certificate.
Certificate saved at:
  /etc/letsencrypt/live/yourdomain.com/fullchain.pem
Key saved at:
  /etc/letsencrypt/live/yourdomain.com/privkey.pem
This certificate expires on 2025-05-30.
Certbot has configured automatic renewal.

Once the certificate is successfully issued, you can log in to your GeoCerts CertCommand Management Console to view the new certificate order. You’ll see details like the order ID, domain name, certificate status, cost, and expiration date—all updated in real time. This provides a convenient way to track and manage your ACME-issued certificates alongside your other orders.


Step 4: Verify NGINX Configuration

Certbot will automatically:

  1. Obtain the certificate
  2. Configure NGINX to use the certificate
  3. Set up automatic redirects from HTTP to HTTPS
  4. Configure certificate auto-renewal (defaults to 30 days before expiration)

Verify your NGINX configuration:

sudo nginx -t

If the test is successful, reload NGINX:

sudo systemctl reload nginx

Step 5: Test HTTPS Access

Visit your domain in a web browser using https:// to verify the certificate is working correctly.


Automatic Renewal

Certbot automatically sets up a systemd timer to renew certificates before they expire. You can verify the timer is active:

sudo systemctl status certbot.timer

🖥️ Sample Terminal Output:

certbot.timer - Run certbot twice daily
Loaded: loaded (/usr/lib/systemd/system/certbot.timer; enabled; preset: enabled)
Active: active (waiting) since Wed 2025-04-30 09:20:07 UTC; 3 days ago
Trigger: Sat 2025-05-03 13:57:13 UTC; 4h 4min left
Triggers: ● certbot.service

Troubleshooting

Common Issues:

  1. Port 80 Blocked: Ensure port 80 is open and accessible for HTTP-01 validation
  2. NGINX Configuration: Check for syntax errors in your NGINX configuration
  3. File Permissions: Ensure Certbot has proper permissions to modify NGINX configuration
  4. Domain Resolution: Verify your domain correctly resolves to your server’s IP

For more help, refer to the Certbot documentation .


Next Steps

← Back to Workflow Overview