Setting up Let’s Encrypt SSL certificates for Nginx Print

  • 0

Let’s Encrypt is a free and automated certificate authority that allows you to secure your website with SSL/TLS certificates. Using HTTPS is strongly recommended for all websites, as it protects user data, improves trust, and is required for many modern browser features.

This guide explains how to obtain and configure a Let’s Encrypt certificate for Nginx using Certbot, the official client recommended by the Let’s Encrypt project.

Prerequisites

Before starting, ensure that the following requirements are met:

  • A registered domain name pointing to your server’s public IP address
  • Nginx installed and running
  • Ports 80 (HTTP) and 443 (HTTPS) open in your firewall
  • Root or sudo access to the server

Installing Certbot

Certbot is the official Let’s Encrypt client. On Debian and Ubuntu systems, it can be installed using the package manager:

apt update
apt install certbot python3-certbot-nginx

This installs Certbot along with the Nginx plugin, which allows automatic configuration of virtual host files.

Preparing your Nginx configuration

Before requesting a certificate, make sure that your Nginx server block is correctly configured for your domain and responds on port 80.

A minimal example:

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

root /var/www/example;
index index.html index.htm;
}

After making changes, test and reload Nginx:

nginx -t
systemctl reload nginx

Obtaining a Let’s Encrypt certificate

Run Certbot with the Nginx plugin to request and install the certificate automatically:

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

During the process, Certbot will ask for an email address, agreement to the terms of service, and whether HTTP traffic should be redirected to HTTPS.

We recommend enabling automatic redirection to HTTPS for better security.

Resulting Nginx configuration

After successful completion, Certbot updates your Nginx configuration and adds SSL parameters automatically. A typical HTTPS server block will include:

  • Paths to the SSL certificate and private key
  • Recommended TLS settings
  • Optional HTTP to HTTPS redirect

Certificate validity and renewal

Let’s Encrypt certificates are valid for 90 days. Certbot installs a system timer that automatically renews certificates before they expire.

You can test the renewal process manually:

certbot renew --dry-run

If no errors are reported, automatic renewal is working correctly.

Firewall and security considerations

Ensure that your firewall allows inbound traffic on ports 80 and 443. Blocking port 80 may prevent certificate renewal unless DNS-based validation is used.

For enhanced security, consider:

  • Using strong TLS ciphers
  • Enabling HTTP Strict Transport Security (HSTS)
  • Keeping Nginx and OpenSSL up to date

Troubleshooting

If certificate issuance fails, common causes include:

  • Domain not pointing to the correct IP address
  • Nginx not accessible on port 80
  • Firewall or security group restrictions
  • Invalid or conflicting server_name configuration

Certbot logs can be found in /var/log/letsencrypt/.

Need assistance?

If you experience issues or require advanced configurations such as wildcard certificates, custom Nginx setups, or Docker-based deployments, please open a support ticket in the Client Area.


Was this answer helpful?

« Back