Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Apache

How to Secure Apache With Let’s Encrypt on Ubuntu

By Freedom251 Team · · 9 min read

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

The reliable Ubuntu workflow is: point your domain at the server, make Apache reachable on TCP port 80, install Certbot from the Snap package, run sudo certbot --apache -d example.com -d www.example.com, and test renewal with sudo certbot renew --dry-run. Certbot’s Apache plugin proves domain control, installs the certificate, updates the matching VirtualHost, and reloads Apache. Let’s Encrypt certificates last 90 days, so the renewal timer and its dry-run test are part of the setup rather than optional cleanup.

What you need before requesting a certificate

Let’s Encrypt does not issue a certificate merely because Apache is installed. The certificate authority must verify that you control each hostname in the request. For the normal Apache workflow, that verification is an HTTP-01 challenge: Let’s Encrypt makes an HTTP request to your server on port 80 and expects the challenge response from the requested hostname.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A registered domain: Use the real public names visitors will enter, such as example.com and www.example.com.
  • Public DNS: Every requested hostname must resolve to the public address that reaches this Ubuntu server. Check both the apex name and any subdomains you plan to include.
  • Internet reachability: Inbound TCP port 80 must reach Apache during both issuance and renewal. Firewalls, cloud security groups, reverse proxies, and load balancers must pass the challenge request.
  • An Apache VirtualHost: Apache should already be serving the site for the requested names. Certbot uses that configuration to select the site it will modify.
  • Administrative access: The commands below use sudo. You also need enough disk space for the certificate files and Apache configuration changes.

Do not close port 80 after the first successful issuance. Automatic renewal uses the same validation route unless you deliberately choose DNS-01 or another supported arrangement. A site that works over HTTPS but is no longer reachable on port 80 can still fail its next renewal.

Choose the validation and installation method

Most single-server Apache sites should start with the Apache plugin and HTTP-01. Other deployments need a different split between validation and installation. Decide this before running Certbot so you do not accidentally overwrite a carefully managed TLS configuration.

#1 Best Overall
FortiGate-40F Firewall Appliance - 5 Gigabit Ethernet RJ45 Ports, Ideal for Small Businesses (Appliance Only, No Subscription) (FG-40F)
  • Compact and Efficient Design: The FortiGate 40F is designed for small to mid-sized businesses and enterprise branch offices, featuring a compact, fanless desktop form factor that ensures quiet operation and minimizes space usage.
  • Robust Connectivity Options: Equipped with 5 GE RJ45 ports, including 1 WAN port and 4 internal ports, this model provides essential connectivity and flexibility for various network configurations in a small-scale environment.
  • High-Performance Security: Offers up to 1 Gbps IPS throughput and 600 Mbps threat protection throughput, using Fortinet’s purpose-built security processor technology to deliver industry-leading performance and protection for SSL encrypted traffic.
  • Advanced Threat Protection: Integrated with Fortinet’s AI-powered FortiGuard Labs, the FortiGate 40F offers comprehensive cybersecurity, identifying and mitigating both known and unknown threats to maintain robust security across your network.
  • Simplified Management and Deployment: Features a user-friendly management console that provides comprehensive network automation and visibility, coupled with Zero Touch Integration with Fortinet’s Security Fabric for easy deployment.
Approach Inbound port 80 Wildcard certificates Does Certbot edit Apache? What you manage
HTTP-01 with --apache Required; the hostname must reach the server during issuance and renewal No Yes. The Apache plugin authenticates and installs the certificate, then reloads Apache DNS, port 80 reachability, and the Apache VirtualHost
DNS-01 Not required for validation Yes. DNS-01 is the only Let’s Encrypt challenge type that can issue wildcard certificates Usually no; a DNS plugin performs validation, and you choose how to install the files DNS API credentials or the required TXT-record workflow, plus certificate installation
certonly --apache Required when Apache is used for HTTP-01 No for HTTP-01 No certificate installation changes; Certbot obtains the files and you configure Apache or another TLS terminator Apache directives, reloads, and any other service that consumes the certificate

Use --apache when Certbot should make the conventional Apache changes for you. Use certonly --apache when a manually maintained configuration, a separate load balancer, or a non-Apache TLS service must remain authoritative. If port 80 cannot be exposed, DNS-01 avoids an inbound connection to Apache, but it introduces DNS credentials or manual TXT records that must be protected and renewed correctly.

Install Certbot on Ubuntu

Install the current Snap package

Ubuntu’s documented installation is the classic Certbot Snap:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Install Certbot with sudo snap install --classic certbot.
  2. If the certbot command is not found because the Snap binary directory is not on your shell’s path, create the documented link: sudo ln -s /snap/bin/certbot /usr/local/bin/certbot.
  3. Confirm that the command responds before attempting issuance by running certbot --version.

The Snap package supplies the Certbot program and its renewal integration. You do not need to download a certificate manually or copy a private key into Apache yourself when using the normal Apache installer mode.

Issue and install the certificate in Apache

Request every hostname that should be covered

From the Ubuntu server, run:

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

Replace both names with the actual hostnames. Each -d option adds a name to the same certificate. Include the apex name and www explicitly if visitors use both; a certificate requested only for example.com does not automatically cover www.example.com. Add other names only when they resolve to this service and are intended to use the same certificate.

What the Apache plugin does

Certbot’s Apache plugin is both an authenticator and an installer. It identifies the matching VirtualHost, arranges the HTTP-01 challenge, asks Let’s Encrypt to validate the names, writes the certificate configuration, and reloads Apache after a successful change. During the interactive run, Certbot may ask whether HTTP requests should be redirected to HTTPS. Choose the redirect only after confirming that the site and any applications work correctly over HTTPS; leaving HTTP available is sometimes necessary for legacy clients or an upstream proxy design.

Rank #2
Firewall Appliance 10GbE Mini PC with SFP+, Intel Alder Lake N100 (4C/4T) 4xIntel I226-V 2.5GbE 2*Intel 82599ES 10GbE Firewall LTE Router Support AES-NI (N150, NO RAM NO ROM) (N150, NO RAM NO ROM)
  • 【Professional Firewall & NAS SERVER】OAKNODE 10gbe Firewall Appliance Mini PC-MGNASN, a powerful professional firewall router pc equipped with a 12th Gen Alder Lake N100 4C/4T up to 3.4GHz TDP only 6W with Intel UHD Graphics which maximizes the performance of the 2.5GbE port & SFP+ port, bring you a smooth secured and encrypted network environment.
  • 【Rich I/O to meet your needs】Firewall Appliance MGNASN With HDMI 2.0+DP 1.4+TYPE-C(dp 1.2) Support for 3x4K@60Hz together, Dual DDR4 RAM slot support for up to 1x32GB SO-Dimm laptop DDR5 Ram Maximum 5600Mhz and 1xM.2 NVMe/PCIe 3.0x1 2280 SSD slot +1*SATA 3.0 SSD/HDD slots (install externally), also it support boot from TF card slot and it also support PXE/AWOL/Watchdog/GPIO etc. which is perfect for your firewall appliance、VM、Router、home Server needs.
  • 【2xSFP+ 10GbE + 4x2.5GbE】This Firewall Router equipped with 2xIntel 82599ES 10gbe network card and 4*Intel i226-V network card speed maximum up to 2.5GbE(need other device like router, cables etc. also support 2.5Gbe/10gbe)which can bring you more faster and professional network usage(some system not release drivers yet) suggest to install version of below systems: pf-sense plus 23.0X or CE 2.7.X, OPNsense 22.1, OpenWrt, ROS7, ESXI 8 , Proxmox, CentOS etc).
  • 【4G LTE Function supported】This model also support 4G LTE function(mini PCIE slot for 4G modem) and SIM card slot which you can use it as a IOT devices for your server.
  • 【Quality With Warranty】If you have any questions or requirements(like OS installation/ drives/bios updates etc.) on OAKNODE Firewall mini pc MGNASN, PLEASE feel free to contact us. We offered 12 Months warranty for it and WE'LL REPLY YOUR Questions within 12 hours(during Workdays).

Successful issuance gives Apache a certificate and private key managed by Certbot. The exact VirtualHost layout varies by Ubuntu release and by how the site was configured, so inspect the resulting configuration rather than assuming a particular filename or directive ordering.

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

Use certificate-only mode when you need manual control

If another service terminates TLS, or if you maintain Apache’s SSL directives yourself, obtain the files without asking Certbot to install them:

sudo certbot certonly --apache -d example.com -d www.example.com

This still uses Apache for HTTP-01 authentication, but it separates obtaining the certificate from installing it. Configure the consuming service with the certificate and private-key files that Certbot reports, then arrange a renewal deploy hook that reloads that service after a successful renewal. Without that reload, a renewed file on disk may not be used by the running process.

Verify HTTPS before you rely on it

Check the browser result

Open https://example.com and each additional hostname you requested. Inspect the certificate details in the browser and confirm that the subject or alternative names include the hostname in the address bar, that the certificate is currently valid, and that the page loads without mixed-content or application errors. If you enabled the redirect, test an explicit http:// request and confirm it reaches the intended HTTPS URL rather than a different host.

Check Apache’s configuration and reload

Before investigating the certificate authority, make sure Apache accepts its generated configuration. A syntax check catches an accidental edit or an incompatible VirtualHost before a reload:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Netgate 1100 pfSense+ Security Gateway - Firewall, Router, VPN
  • BUSINESS READY - pfSense+ software updates included for product lifetime. Netgate TAC Lite technical support included. One year hardware warranty included.
  • COMPLETE - Pre-loaded with pfSense+ software to get up and running fast. Simply unbox it and start customizing for your secure edge networking needs. Free help with setup from our expert Technical Assistance Center (TAC) available 24/7/365.
  • POWERFUL - A dual core ARM Cortex-A53 1.2 GHz delivers near gigabit routing of common home iPerf3 traffic and in excess of 650 Mbps of firewall throughput.
  • COMPACT - Low power draw, a compact form factor, and silent operation allow it to run unnoticed when placed on a desktop, wall, or rack.
  • FLEXIBLE - Three (3) 1 GbE switched (WAN/LAN/OPT) ports allow you to configure three separate 1 GbE switched ports for upto a gigabit of bi-directional traffic.
sudo apachectl configtest

Certbot normally reloads Apache after installation. If the reload fails, read the Apache error output and correct the configuration before trying Certbot again. A certificate can be valid while Apache is still serving an older configuration, so verify the live HTTPS endpoint after every manual change.

Make renewal automatic and prove that it works

Understand the 90-day lifecycle

Let’s Encrypt certificates are valid for 90 days. Ubuntu’s documented Certbot setup installs a systemd timer named snap.certbot.renew.timer; the default timer attempts renewal twice daily. Certbot renews only certificates that are within its renewal window, so these frequent attempts do not replace a healthy certificate twice a day.

Inspect the timer

Check that the timer exists and is scheduled:

sudo systemctl status snap.certbot.renew.timer
sudo systemctl list-timers snap.certbot.renew.timer

The status output should show an active timer and a next-run time. A timer alone is not proof that the Apache validation path still works; DNS, firewall, proxy, or VirtualHost changes can break renewal months after issuance.

Run a safe dry run

Test the complete renewal path without replacing the live certificate:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo certbot renew --dry-run

A successful dry run demonstrates that Certbot can perform the renewal process with the current challenge and plugin settings. Run it immediately after initial setup, after changing DNS or firewall rules, and after major Apache or load-balancer changes. If you used certonly and a separate TLS service, confirm that your deploy hook also reloads that service during a testable renewal event; the certificate files alone do not update an already running process.

Rank #4
VNOPN Fanless Firewall Appliance Intel J3710 4C/4T, Firewall Mini PC, 4 x Intel i226 LAN Ports, Network Gateway, Soft Router, Support PF-Sense/OPN-Sense, AES-NI (8GB RAM 128GB SSD)
  • 【Processor & OS】Firewall Mini PC with Intel J3710 CPU up to 2.64GHz, 4Cores 4threads 2MB L2 Cache, TDP 6.5w, supports AES-NI. It tested with pf-sens/opn-sense linux ubuntu and other popular open source os. ("DEL" key to enter BIOS)
  • 【Interfaces】The firewall pc has 4 * Intel I226 lan ports, 2 * USB3.0 ports, 1 * RS232COM port, 2 * HD port, 1 * DC port. Equipped with VESA mount, you can install the micro pc behind the monitor to save space.
  • 【Fanless Design】only 6.5W; fanless heat dissipation design, aluminum alloy shell, efficient and fast heat dissipation, which can withstand temperatures up to 60°C. support 24/7 hours working, no noise.
  • 【RAM & Storage】The firewall router equipped with 8G DDR3 RAM, max support 8GB; 128GB mSATA SSD, up to 512GB. Not support HDD. Size:5.27 * 4.98 * 1.43 inches, Weigh:500g, small but powerful.
  • 【12 Months Service】You will get a firewall pc and accessories,If you encounter any problems during the use, please contact us through Amazon, we have a professional and efficient team dedicated to serving you.

Use DNS-01 when HTTP-01 is the wrong fit

When DNS-01 is appropriate

Choose DNS-01 when inbound port 80 cannot be exposed, when a wildcard such as *.example.com is required, or when validation must happen independently of the Apache host. Let’s Encrypt’s documentation identifies DNS-01 as the only challenge type that can obtain wildcard certificates.

DNS-01 proves control by checking a TXT record at the required DNS name. It does not require an inbound connection to Apache, but Certbot must be able to create that TXT record through a supported DNS plugin or you must create it manually. DNS API credentials can change every DNS record in an account, so give the plugin the narrowest permissions your provider supports and keep the credential material out of publicly readable files.

Plan installation separately

A DNS plugin performs validation; it is not automatically an Apache installer. After validation, install the resulting certificate in Apache or use certonly for a service that terminates TLS elsewhere. If the service is not Apache, add a renewal deploy hook that reloads it. Test both the DNS update and the service reload rather than assuming that a successful first issuance covers future renewals.

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

Troubleshoot the common failure points

Validation says the hostname cannot be reached

  • Verify that every -d hostname resolves publicly to the correct address. A stale record, split-horizon DNS, or an unintended IPv6 record can send the challenge to another machine.
  • Confirm that TCP port 80 is allowed in the Ubuntu firewall, cloud security group, hosting firewall, load balancer, and router. All layers must forward the request to the Apache host.
  • Check that Apache is listening for the hostname and that the relevant VirtualHost is enabled. Certbot cannot complete HTTP-01 if the request lands on an unrelated site.
  • Keep the site reachable for the entire issuance attempt. Temporarily stopping Apache or switching DNS while validation is in progress can invalidate the challenge.

A redirect or proxy breaks the challenge path

HTTP-to-HTTPS redirects are compatible only when the challenge request can still reach the validation response. Review redirect rules, reverse-proxy mappings, and load-balancer health checks so the ACME challenge path is forwarded to the Apache instance serving it. If a proxy terminates HTTP elsewhere, run the challenge where that proxy can answer it or switch to DNS-01.

Another service already owns port 80

The Apache plugin expects Apache to serve the HTTP-01 response. If a different web server occupies port 80, either arrange for Apache to handle the challenge through your front end or use DNS-01. Certbot’s standalone mode is a different option that starts a temporary server, but it also requires port 80 to be free; it cannot coexist with a service already bound there.

Best Value
Firewall Mini PC, Intel J1900 4-Port i210 Router, 4GB RAM 64GB SSD
  • 【CPU Optimized for Firewall Mini PCs】This firewall appliance is powered by Intel Quad-Core Celeron J1900, 64-bit, up to 2.0 GHz, supporting software-based encryption. Energy-efficient and reliable, it runs 24/7 for home or small office networks, handling VPNs, multi-WAN routing, and basic firewall tasks efficiently.
  • 【4×Intel i210 Ports】Equipped with four Intel i210 network controllers, each delivering up to 1 GbE for reliable multi-WAN routing, VPN connections, VLAN management, and stable performance in small office or home firewall deployments
  • 【Memory & Storage】This Firewall Mini PC comes with 4 GB DDR3L RAM and a 64 GB mSATA SSD, providing reliable performance for basic networking tasks. AMI BIOS with ACPI support ensures stable system operation and energy-efficient 24/7 use
  • 【Flexible System Compatibility】Compatible with Windows 10, Linux, and professional firewall systems such as pfSense, OPNsense, and VyOS, ensuring stable network management for home or small office use
  • 【After-Sales Support:】This compact, fanless, and silent firewall keeps your network secure. Includes lifetime technical support and a 30-day money-back guarantee!

Apache reload fails after issuance

Run sudo apachectl configtest and inspect Apache’s configuration and logs for the directive or VirtualHost that failed. Correct the syntax or conflicting module, then reload Apache and revisit the HTTPS URL. Do not assume that a successful certificate order means the live web server accepted the new configuration.

The dry run fails after the site worked initially

Start with the same checks as a first issuance: public DNS for every name, TCP 80 reachability, the active Apache VirtualHost, and any proxy or redirect in front of it. Then inspect the timer status and Certbot’s output. Configuration drift is common: a new firewall rule, moved load balancer, changed DNS target, or replacement web server can leave the original certificate valid while making renewal impossible.

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

The certificate renews but the site still serves the old one

This usually means the certificate files were replaced but the TLS-terminating process was not reloaded. The normal --apache workflow reloads Apache automatically. A certonly workflow or a separate TLS terminator needs an explicit renewal deploy hook that reloads the consuming service; test that hook as part of your operational check.

A repeatable maintenance checklist

  • Keep public DNS records for every certificate name pointed at the service that will answer validation.
  • Keep TCP port 80 reachable for HTTP-01, including through any proxy or load balancer.
  • Check snap.certbot.renew.timer after package, server, or operating-system maintenance.
  • Run sudo certbot renew --dry-run after major DNS, firewall, Apache, or proxy changes.
  • After a successful renewal test, open each HTTPS hostname and inspect the certificate actually presented to clients.
  • If you use certonly, verify the deploy hook reloads every service that terminates TLS.

For a conventional Ubuntu server where Apache serves the public site, sudo certbot --apache with all required -d names is the shortest safe path. The essential security property is not the first green padlock; it is a tested renewal path that still reaches the correct host months later.

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.

ApacheCertbotHTTPSLet’s EncryptLinux administrationSSL/TLSUbuntu

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.

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.