in

How to Setup Nginx with Let‘s Encrypt Certificates (A Comprehensive Guide)

Enabling HTTPS on your Nginx website is critical these days, and I want to provide you with a complete guide to properly implementing TLS certificates from Let‘s Encrypt. I‘ll share my insights as an experienced DevOps engineer to help you fully understand the importance, options, and best practices when using free certificates on Nginx.

Why HTTPS and Certificates Are Crucial in 2025

Secure web traffic with HTTPS and TLS should now be considered mandatory for all sites due to:

Encrypting Data – Encryption prevents man-in-the-middle tampering and eavesdropping. This protects sensitive user information like passwords, names, addresses and credit card numbers from being stolen or modified during transit between the browser and your server.

SEO Rankings – Google has made it clear that HTTPS is a ranking factor and will provide a slight boost. They also tag HTTP pages as "not secure" to push adoption.

Industry Standards – Organizations like PCI Security Council require HTTPS for compliance when processing credit cards or other financial data. The Internet Society warns that unencrypted HTTP is simply unsafe for websites today.

Let‘s Encrypt offers free, trusted certificates to enable HTTPS on most personal, small business and organization websites at no cost.

According to W3Tech‘s survey of the top 10 million sites, over 73% of all websites now use Let‘s Encrypt certificates to achieve HTTPS.

However, ecommerce sites handling payments may want to purchase a vetted commercial certificate from a provider like DigiCert or GlobalSign for additional verification and reassurance to customers.

What Exactly is Let‘s Encrypt?

Let‘s Encrypt is an open certificate authority (CA) run by the non-profit Internet Security Research Group (ISRG), allowing anyone to obtain free browser-trusted TLS certificates. Here are some key facts about Let‘s Encrypt:

  • 150 million+ active certificates issued
  • 100+ certificate authorities who trust Let‘s Encrypt
  • 90-day certificate validity period requiring renewal
  • ACME protocol used for automatic issuance and renewal
  • Supported by Mozilla, Cisco, Facebook, Chrome and others

The short 90-day lifespan of Let‘s Encrypt certificates increases security by ensuring any compromised private keys are quickly cycled out. But it means you must automate renewal. I‘ll cover the best methods later in this guide.

Now let‘s dive into how to install and configure Let‘s Encrypt certificates on your Nginx server…

Option 1 – Using Certbot to Automate Deployment

The easiest way to implement Let‘s Encrypt certificates is by using Certbot. Certbot is an official Let‘s Encrypt client created by the EFF that automates certificate issuance and configuration.

Here are the key steps if you want Certbot to handle deploying your certificate:

  1. Install Certbot and the Nginx plugin on your Ubuntu/Debian server:
sudo apt update
sudo apt install certbot python3-certbot-nginx
  1. Run Certbot to issue a new cert and modify Nginx config:
sudo certbot --nginx

Certbot will automatically modify your Nginx configuration to enable HTTPS and redirect HTTP traffic. This works perfectly for simpler setups.

However, for more complex configurations, you may want more control over the Nginx changes. In that case, use the certonly option:

sudo certbot --nginx certonly

This will just issue and renew the certificates without altering your Nginx config files.

  1. Test renewal and forced renewals:
sudo certbot renew --dry-run
sudo certbot renew --force-renewal

Certbot provides the simplest way to rollout Let‘s Encrypt certificates on Nginx. But the lack of config control won‘t suit all scenarios, which leads us to…

Option 2 – Manual Issuance and Configuration

For more advanced users, you can opt to manually request Let‘s Encrypt certificates and configure Nginx yourself. Here‘s an overview:

  1. Use the SSL For Free ACME client to generate certificate files after proving domain ownership.

  2. Download the .crt, .key and .cabundle files to your Nginx server.

  3. Concatenate the .crt and .cabundle into a combined .crt:

    cat domain.crt domain.cabundle > domain.combined.crt
  4. Add the paths and settings to your Nginx server { } block:

    server {
      listen 443 ssl;
      ssl_certificate /path/to/domain.combined.crt;
      ssl_certificate_key /path/to/domain.key;
    }

The manual method requires more understanding but offers complete control over the TLS certificate issuance and Nginx configuration process.

Expert Tips for Optimal HTTPS

Here are some additional tips from my experience securing sites with HTTPS and Let‘s Crypt to ensure optimal security and performance:

  • Automate renewal using cron jobs or systemd timers to reissue certificates automatically before expiration.

  • Redirect all HTTP to HTTPS to prevent accidental unencrypted connections.

  • Test your site with tools like SSL Labs to identify and fix any vulnerabilities.

  • Monitor expiration dates so you‘re alerted to renewals and can replace compromised keys.

  • Purchase commercial certs from trusted CAs for business-critical sites and apps handling financial data.

  • Always run the latest stable Nginx for important security patches and features.

  • Change default Nginx ports to increase security against automated attacks and scripts.

  • Enable HTTP/2 support within Nginx for better performance if compatible with your server and apps.

Properly configuring TLS certificates prevents MITM attacks, reassures visitors, and unlocks SEO benefits. Let‘s Encrypt makes enabling HTTPS easy and affordable for virtually any Nginx site.

I hope this guide has provided you with a comprehensive overview and helpful tips for setting up Nginx with Let’s Encrypt certificates to maximize security and performance. Please let me know if you have any other questions!

AlexisKestler

Written by Alexis Kestler

A female web designer and programmer - Now is a 36-year IT professional with over 15 years of experience living in NorCal. I enjoy keeping my feet wet in the world of technology through reading, working, and researching topics that pique my interest.