Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Secure Nginx With Let’s Encrypt on Ubuntu

Set up a trusted Let’s Encrypt certificate on Ubuntu Nginx with Certbot, force HTTP-to-HTTPS redirects, choose the right ACME challenge, and verify automatic renewal before expiry.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Certbot’s Nginx integration. Point every hostname at the Ubuntu server, make sure Nginx has an enabled server block for those names, install Certbot from the snap, and run sudo certbot --nginx -d example.com -d www.example.com. Choose the HTTP-to-HTTPS redirect when prompted, then verify the site and test renewal with sudo certbot renew --dry-run. This gives Nginx a Let’s Encrypt certificate and prepares scheduled renewals without manually editing most TLS settings.

What this setup does

Let’s Encrypt issues publicly trusted TLS certificates through the ACME protocol. Nginx presents the certificate to browsers, allowing visitors to use HTTPS instead of sending HTTP traffic in clear text. Certbot handles the ACME validation exchange, writes the certificate files, updates Nginx when you use its Nginx plugin, and arranges recurring renewal on a snap-based Ubuntu installation.

As an Amazon Associate I earn from qualifying purchases.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ubuntu Server documentation describes Certbot as the recommended ACME client for Let’s Encrypt. The snap distribution is also designed to keep Certbot current and includes automated renewal preconfigured. The certificate itself is not permanent: your operational job is to prove that renewal works before the current certificate approaches expiry and to ensure Nginx reloads the renewed files.

Check the prerequisites before installing Certbot

Point DNS at the Ubuntu host

Create or verify an A record for each IPv4 hostname and an AAAA record for each IPv6 hostname you intend to place on the certificate. Every record must resolve to the Ubuntu server that will answer the ACME challenge. If example.com and www.example.com resolve to different machines, validation can reach the wrong server even though Nginx is correctly configured on one of them.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Check both the apex name and aliases you will pass with -d. DNS changes can take time to appear at different resolvers, so do not begin validation until the records consistently point at this host. A stale AAAA record is a common cause of apparently random failures: an authority may try IPv6 while you are testing over IPv4.

Make sure Nginx has the right server block

Nginx must have an enabled server block whose server_name contains every hostname requested from Certbot. On Ubuntu, enabled configuration files are normally visible in /etc/nginx/sites-enabled/. Check that directory and confirm the intended file is linked or otherwise loaded by the main Nginx configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before asking Certbot to edit anything, validate the current configuration:

sudo nginx -t

Fix any syntax or include error reported by that command. Certbot’s Nginx plugin needs a configuration it can parse and a matching server block in which it can add TLS directives. If Nginx is not already serving the requested names, certificate issuance cannot reliably select the correct virtual host.

Keep port 80 reachable for the normal flow

The usual Nginx flow uses the HTTP-01 challenge. The certificate authority must be able to connect to your public server on TCP port 80 and retrieve the challenge response. Allow that traffic through the host firewall and any cloud security-group or edge firewall in front of the machine. Also ensure that another service is not intercepting the hostname on port 80.

You can choose a different validation method when port 80 cannot be exposed, but deciding that in advance prevents a failed automated run from being mistaken for a certificate or Nginx problem.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Certbot from the snap

On Ubuntu, install the snap package with:

sudo snap install --classic certbot

If the certbot command is not on your shell path after installation, expose the snap’s executable at a conventional location:

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
sudo ln -s /snap/bin/certbot /usr/local/bin/certbot

Using the snap is the documented route in this procedure. It keeps Certbot separate from the operating system’s older package set and supplies the renewal timer used later in this guide.

Obtain and install the certificate automatically

Request every hostname in one certificate

Run one -d option for each name that should be covered:

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

The names become the certificate’s Subject Alternative Name (SAN) set. Include all public aliases that visitors will use; obtaining a certificate for only the apex name does not cover www.example.com, and the reverse is also true. If you add another hostname later, run Certbot again with the complete desired set rather than assuming an existing certificate will acquire it automatically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the --nginx plugin changes

Certbot’s Nginx plugin locates the server block matching the requested names, performs the ACME validation, and adds the TLS directives needed to serve the resulting certificate. After a successful configuration, it reloads Nginx so the running process uses the new settings. This is the fastest path when you want Certbot to manage the integration instead of hand-editing the virtual host.

During the command, Certbot asks how HTTP requests should be handled. Choose the redirect option so requests arriving at http://example.com are sent to https://example.com. Without that choice, the certificate may be valid while users continue reaching an unencrypted HTTP endpoint unless they type the HTTPS URL themselves.

Verify the result immediately

Open the HTTPS URL for each hostname in a browser and inspect the certificate details. Confirm that the displayed names include the hostname you visited and that the page is being served by the expected Ubuntu host. Also test an HTTP URL and confirm it redirects to HTTPS, rather than returning a separate site or an error.

If the page is not the expected virtual host, stop and correct Nginx before attempting repeated issuance. A valid certificate attached to the wrong server block still produces a wrong-certificate warning for users.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Use manual Nginx configuration when you need control

Obtain files without letting Certbot rewrite the server block

Use the certonly form when you want Certbot to complete issuance but intend to design or maintain the Nginx TLS configuration yourself:

sudo certbot certonly --nginx

This mode obtains the certificate through Nginx-assisted validation while leaving the final TLS wiring to you. It is useful when your configuration is generated by another system, when you need a carefully structured set of server blocks, or when an automatic edit would conflict with local conventions.

Reference the live certificate paths

Certbot stores the active certificate material under /etc/letsencrypt/live/<domain>/. A typical Nginx HTTPS server block references the full chain and private key as follows:

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

The fullchain.pem file supplies the server certificate together with the intermediate chain that clients need. The private key must remain readable only by the accounts and services that require it. Do not copy the key into a public document root or commit it to a configuration repository.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

After editing the server block, run sudo nginx -t. Only when the test succeeds should you reload Nginx. A reload applies the new certificate without the interruption associated with stopping and starting the service.

Choose the right ACME validation method

Validation proves control of the hostname. The method determines which network path or DNS capability is required; it does not change the trust model of the resulting certificate.

Method Port 80 reachability Nginx handling Wildcard certificates DNS API requirement Operational profile
HTTP-01 Certificate authority must reach the server on port 80 Normal Nginx flow; the Nginx plugin can configure the challenge and TLS settings Not suitable for wildcard validation None Usually the simplest choice for a public Nginx site
Standalone Port 80 must be free for Certbot’s temporary web server Existing Nginx listener cannot occupy the required port during validation Not suitable for wildcard validation None Useful when no web server can answer the challenge, but it introduces a listener conflict and service coordination
Webroot Certificate authority must reach the existing site on port 80 Challenge files are placed in the existing document root; you retain configuration control Not suitable for wildcard validation None Works when the document root and routing are predictable
DNS-01 Inbound port 80 is not required Nginx does not have to answer an HTTP challenge Supports wildcard certificates Usually requires a Certbot plugin or other integration for the DNS provider’s API More involved to automate, but appropriate for private origins, blocked HTTP, and wildcard names

The exact DNS-01 command depends on the DNS provider plugin, so use that provider’s Certbot integration rather than guessing a generic flag. Grant the plugin only the DNS permissions it needs; DNS credentials can change the records for the entire zone and therefore deserve stricter protection than ordinary web configuration.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Understand the two Nginx integration modes

Choice Certificate issuance Nginx TLS edits Best fit
sudo certbot --nginx -d ... Certbot obtains the certificate and completes validation Certbot finds the matching server block, adds TLS directives, and reloads Nginx after success A conventional site where automated configuration is acceptable
sudo certbot certonly --nginx Certbot obtains the certificate using Nginx-assisted validation You maintain the TLS directives and reload process Generated or tightly controlled Nginx configurations that should not be rewritten automatically

Both modes rely on the same underlying certificate files. The difference is who owns the final Nginx configuration and the timing of the reload.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set up and verify automatic renewal

Run a safe renewal rehearsal

Do not wait for an expiry incident to discover that DNS, port access, or a virtual-host change has broken renewal. Run:

sudo certbot renew --dry-run

The dry run exercises the renewal process without issuing or saving a production certificate. Treat a failed dry run as an operational defect: read the reported challenge, correct the underlying DNS, listener, firewall, or Nginx issue, and run the dry run again.

Check the snap renewal timer

On a snap-based installation, inspect the systemd timer with:

sudo systemctl status snap.certbot.renew.timer

Ubuntu documents that the scheduled job attempts renewal twice daily. Those attempts do not mean a new certificate is issued twice a day; Certbot renews only when a certificate is within its renewal window. The repeated schedule gives transient DNS or network problems another opportunity to succeed before expiry.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know what happens after a successful renewal

When the Nginx plugin is managing the site, Certbot reloads Nginx after a successful renewal. The running workers then read the renewed certificate while existing connections can finish normally. If you used certonly and maintain Nginx yourself, make sure your own renewal process includes a configuration test and reload at the appropriate time.

Services outside Certbot’s Nginx or Apache plugin flow do not receive that automatic reload. For those services, create a deploy hook such as /etc/letsencrypt/renewal-hooks/deploy/reload-service.sh that runs systemctl reload <your-service>. The hook must target the service that actually presents the certificate; reloading Nginx will not update an unrelated daemon.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Troubleshoot the failures that matter most

HTTP-01 reports that port 80 cannot be reached

  • Confirm the A and AAAA records resolve to this Ubuntu server, not an old address or another proxy.
  • Allow inbound TCP port 80 in the host firewall and any external security group.
  • Check that another service is not intercepting the hostname or answering with an unrelated site.
  • Verify that Nginx is listening for the requested name and that its enabled server block is loaded.

After correcting the cause, rerun the issuance command or the renewal dry run. Changing the certificate command without fixing reachability will produce the same challenge failure.

The browser shows the wrong certificate or site

Inspect the files under /etc/nginx/sites-enabled/ and compare each server_name with the hostname in the browser. Nginx selects a server block by the requested name; a missing alias or an unintended default block can therefore present a different certificate. Run:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo nginx -t

Once the intended block is correct and the test passes, reload Nginx. Then revisit the HTTPS URL and inspect the certificate names again.

Renewal fails even though initial issuance worked

Start with sudo certbot renew --dry-run and use the specific challenge error as the branch point. DNS may have changed, a firewall rule may have tightened, port 80 may now be occupied by another process, or an Nginx edit may have broken the matching server block. Check the timer status with sudo systemctl status snap.certbot.renew.timer after the configuration is repaired so you know the scheduler is active.

Do not revoke or replace a still-valid production certificate merely because one test failed. Correct the cause, obtain a successful dry run, and keep the existing certificate serving traffic while the renewal window remains open.

A certificate is missing one of several names

Pass every required hostname with its own -d flag in one command. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo certbot --nginx -d example.com -d www.example.com -d api.example.com

Then verify each name independently over HTTPS. A SAN certificate can contain several names, but only the names explicitly requested are covered.

Standalone validation cannot bind to port 80

Standalone mode runs a temporary web server, so Nginx or any other listener must leave port 80 free during the challenge. If stopping or coordinating that listener is undesirable, use the Nginx or webroot flow instead. If inbound HTTP is impossible altogether, DNS-01 avoids the port requirement and is the method that supports wildcard names.

A practical operating checklist

  • Each requested hostname has correct A and, where used, AAAA records.
  • Nginx has an enabled server block listing every requested name.
  • sudo nginx -t succeeds before Certbot edits or reloads the service.
  • The chosen validation method matches your firewall, listener, and DNS capabilities.
  • The HTTP-to-HTTPS redirect is selected when Certbot offers it.
  • Every HTTPS hostname displays the intended certificate after issuance.
  • sudo certbot renew --dry-run completes successfully.
  • sudo systemctl status snap.certbot.renew.timer shows the scheduled renewal job is present.
  • Any service not handled by the Nginx plugin has a deploy hook that reloads that service after renewal.

Conclusion

For a standard public Nginx site, the reliable path is DNS verification, a valid enabled server block, the Certbot snap, and sudo certbot --nginx with one -d flag per hostname. Select the HTTPS redirect, verify each name, and prove renewal with a dry run. Choose certonly --nginx when configuration ownership must remain manual, and switch to DNS-01 when port 80 is unavailable or a wildcard certificate is required.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.