Skip to content

9. HTTPS and Certificates, From the Operator's Chair

“A padlock is a promise with an expiry date.”

The story: the padlock that expired on a Sunday

Section titled “The story: the padlock that expired on a Sunday”

This one is a composite, built from a pattern most operators have lived through. A dance academy in Pune runs its booking site on a small VPS. Bookings come in through a Next.js app, payments clear through Razorpay, and Razorpay’s webhooks call the academy’s HTTPS endpoint to confirm each payment. On a Sunday evening, students start reporting a red warning page: “Your connection is not private.” Razorpay’s webhooks start failing too, because their client refuses to talk to a server whose certificate has expired.

Nobody changed the code. The certificate had been renewing automatically for months. The renewal had quietly started failing three weeks earlier, when someone tightened the firewall and closed port 80. Renewal needed port 80 to prove the server controlled the name, and the proof never arrived. The certificate ran out at midnight, and the first person to notice was the owner, at a quarter to nine, asking why the page was red.

The fix took four minutes once the cause was clear. Finding the cause took most of an evening, because the symptom sat in the browser and the cause sat in a log file nobody had opened since the firewall change.

You know how to deploy this stack. You have probably put Next.js behind nginx or Caddy and watched the padlock appear. What you may not know is what the padlock is actually promising, who is allowed to make that promise, what your server must hold to keep it, and why a promise with an expiry date needs a machine to keep renewing it. That is this chapter.

Quick recap first, then the operator’s view. Book 1 covered TLS from the outside: a handshake, a certificate that names a server, and a list of authorities your browser trusts. If you want that picture again in full, read the TLS material in the Glue Book’s network chapter before you carry on. This chapter stays on your side of the wire. It asks what you install, where the key lives, who renews, what changes when Cloudflare sits in front, and what breaks when nobody is watching a date.

Keep the mantra in view, because this chapter sits at the receptionist’s desk:

Name → Address → Route → Door → Guard → Receptionist → App

The receptionist is the reverse proxy from Chapter 8. For most small setups it is the piece that holds the certificates and shows them to visitors. The guard, when you have one, is Cloudflare, and it has its own opinions about the badge the receptionist carries. Keep both in mind as we go.

The operator’s view: what a certificate really is

Section titled “The operator’s view: what a certificate really is”

A certificate is a signed sentence. It says that this public key belongs to this name, that it is valid from this date to that date, and that a named authority vouches for it. The authority signs the sentence with its own private key. Your visitor’s browser ships with a list of authorities it trusts, so when the signature checks out, the browser believes the sentence.

That is the whole trick. Your server is not proving it is good. A third party the browser already trusts is saying, in writing, that the key on your server is the one that belongs to the name.

Three pieces matter on your side of the wire.

  • The leaf certificate. This is the sentence about your name. It is public. Your server hands it to every visitor during the handshake, and anyone can read it with a tool.
  • The private key. This is the secret that matches the public key inside the leaf. It is generated on the machine that terminates TLS, and it should never leave that machine. If it leaks, the certificate is no longer worth trusting, and you reissue.
  • The chain. The leaf is signed by an intermediate authority, and the intermediate is signed by a root. Roots live offline and rarely sign anything directly. Browsers and operating systems ship with the roots in their trust stores. Intermediates do the daily signing.

Figure 9.1 shows the chain the way an operator needs to see it.

Chain of trust from root to leafThree boxes in a row. A root CA in the browser trust store signs an intermediate CA, which signs the leaf certificate on your server. A dashed line hangs from the leaf to a private key box that stays on the server.trusted by the browsersigns daily, onlinesent by your serverRoot CAkept offlinesigns intermediatesIntermediate CAsigns leaf certswhat issuers use day to dayLeaf certificatepipeslab.innames your serversignssignsPrivate keynever leaves this serverThe browser checks leaf, then intermediate, then root.Your server must send the leaf and the intermediate.The root is never sent. The visitor already has it.
Figure 9.1. Your server sends the leaf and the intermediate. The browser already holds the root.

The rule for you is short. Your server sends the leaf and the intermediate. It does not send the root, because the visitor’s browser is supposed to have it already. Most certificate tools hand you a bundle file that contains the right pieces in the right order, so use the bundle, not the leaf file on its own.

The private key deserves its own care. Keep it readable by the process that needs it and by nobody else. Keep it out of git, out of Docker image layers, out of chat windows, and out of screenshots of your nginx config. Most key accidents happen when someone copies a folder to a new server and forgets which files were secret.

Here is a question that sounds too basic to ask. How does one IP address serve five different websites over HTTPS?

The TLS handshake happens before any HTTP request. The browser’s first message, the ClientHello, is where it says which name it wants, and the server has to answer with the right certificate before it has read a single header. The name travels in a field called Server Name Indication, or SNI. Your server reads it, finds the matching certificate and key, and carries on with the handshake.

Before SNI was widely supported, the trouble was real. A server could not tell which name the visitor wanted until after the handshake, so each HTTPS site needed its own IP address and its own certificate. Addresses were scarce and dedicated IPs were a line item on the bill. SNI, which spread widely from the late 2000s onward, let one address carry many TLS names. That is why you can run your academy app, its staging copy, and an admin tool on one VPS and one port 443.

Figure 9.2 shows the name picking the badge.

SNI choosing a certificate on one IP addressA visitor sends a ClientHello carrying the name app.pipeslab.in. The receptionist on one IP and port 443 reads that name and presents the matching certificate. Other names on the same address get their own certificates.VisitorClientHelloSNI: app.Receptionistpicks cert by nameport 443, one IPCert: app.app.pipeslab.inCert: api.api.pipeslab.inCert: staging.staging.pipeslab.inSame IP, same port. Only the name in the first message tells them apart.
Figure 9.2. One address, one port, many certificates. The name in the first message chooses which badge the receptionist shows.

Your receptionist does this lookup for every name it serves. The app behind it never sees the handshake at all. That is one more reason the certificate belongs at the proxy, which is the subject of the rest of this chapter.

Encrypted Client Hello is the work in progress to hide the name as well. It is not universal yet, so assume anyone on the path can see which name a visitor asked for, even though they cannot see the page.

Let’s Encrypt and ACME: the day certificates became free

Section titled “Let’s Encrypt and ACME: the day certificates became free”

Before about 2015, a certificate was a purchase. You generated a request file, sent it to a vendor, clicked a verification link, paid a yearly fee, and put the expiry date in your calendar. Plenty of small sites ran without the padlock, because the padlock had a price and the price came with paperwork.

Then the Internet Security Research Group, a nonprofit, started issuing certificates for free under the name Let’s Encrypt. It went public around 2015 and opened to everyone in 2016, if memory serves. The free part made the headlines. The automation changed the web. The protocol behind it is ACME, written up as RFC 8555 in 2019. ACME lets a client on your server ask for a certificate, prove that you control the name, and install the result. No email. No calendar. No purchase order.

Three things followed. Renewal became a background task instead of an annual panic. Lifetimes could shrink, because short certificates cost nothing when a robot does the renewing. And HTTPS stopped being a premium feature for a booking page. Browser makers pushed in the same years, and most of what you visit now shows the padlock by default.

ACME is a short conversation. Your client opens an order for a name. The authority replies with a challenge. Your client answers it, and the authority checks the answer. If the check passes, the authority signs a certificate for a key your client generated. Figure 9.3 shows the sequence for the most common challenge.

HTTP-01 challenge between your server and the certificate authorityTwo lifelines. Your server asks for an order, receives a token, serves it on port 80, and the authority fetches it over the internet. If port 80 is closed, the fetch fails and no certificate is issued.Your serverruns the ACME clientLet’s Encryptthe certificate authority1 new order for app.pipeslab.in2 challenge: a token to publish3 serve token on port 804 authority fetches token over port 80port 80 closed?step 4 failsno cert5 send the CSR, ask for the certificate6 leaf and intermediate issuedRenewal repeats this exchange on a timer, without you.
Figure 9.3. HTTP-01 in six moves. The proof travels over port 80, so port 80 must be reachable from the internet.

The authority needs proof that you control the name. ACME offers three ways to show it.

HTTP-01 asks you to place a secret token at a fixed path on the name, under /.well-known/acme-challenge/, and the authority fetches it over port 80 from the open internet. It is the easiest option with a web server you already run, and most tools default to it. Its hard requirement is port 80 reachable from outside. It proves one name at a time, so it cannot issue a wildcard.

DNS-01 asks you to publish the token as a TXT record under _acme-challenge for the name. The authority checks DNS, so no port needs to be open, and it is the only challenge that proves a wildcard. The cost is that something must write DNS records, which usually means an API token for your DNS provider. That token is a secret that lives on your server, so guard it like the private key. Chapters 10 and 11 explain why DNS is the piece that proves it.

TLS-ALPN-01 proves control inside the TLS handshake on port 443, using a special application protocol tag. It needs port 443 reachable and a TLS terminator that can answer the special handshake. Caddy supports it and, as of my knowledge, tries it alongside HTTP-01 by default. You rarely pick it by hand, but it earns its keep when port 80 is closed and 443 is open.

Certbot is the Electronic Frontier Foundation’s client. You ask it for a certificate, it writes files under a folder in /etc/letsencrypt, and a timer runs it on a schedule. Renewal then needs a deploy hook that reloads nginx, because a renewed file on disk does nothing until the process holding it reloads. The hook is the step people forget.

Caddy takes a different view. It obtains a certificate the first time it sees a site address, stores it in its own data directory, renews it before expiry, and reloads itself. You write the name and the upstream, and the certificate becomes Caddy’s problem. For one VPS running a Next.js app behind one proxy, that is the default I would pick. Certbot with nginx is perfectly good when you already have it working, and it is the right tool when other software must read the same files.

Renewal and expiry: short lifetimes are a feature

Section titled “Renewal and expiry: short lifetimes are a feature”

A certificate has two dates that matter: the day it starts being valid and the day it stops. The second one produces the 2 a.m. call. Nothing in the protocol warns the visitor that the badge has expired. The browser shows a full-page warning, and most people, sensibly, leave.

It is tempting to hear “ninety days” and feel it is a nuisance. It is the reverse. A short lifetime means every mistake in your renewal path shows up in weeks, not years. Before free certificates, paid ones often lasted a year or two, and renewal happened once in a long while. The steps lived in a wiki nobody updated, and the one person who knew them left the company. A three-year certificate is a time bomb with a three-year fuse, and nobody remembers the fuse.

Let’s Encrypt picked ninety days on purpose. That is long enough that a renewal can fail for a week and nobody is hurt, and short enough that a broken process gets caught while the engineer who built it still works there. Automation does the rest.

The industry has moved the same way. Around 2025 the CA/Browser Forum, the body whose rules browsers enforce, voted to shorten the maximum lifetime of publicly trusted certificates in stages. If memory serves, the steps run from roughly 200 days in 2026, to about 100 in 2027, to around 47 days by 2029. Treat those numbers as approximate and check the current ballot before you plan around them. Let’s Encrypt has also been offering short-lived certificates, around six days long, for people who want revocation to matter less. That option was still new as of the mid-2020s, so hedge accordingly.

Certificate lifetimes, drawn to scaleThree bars show certificate lifetimes. Today the public maximum is about ninety days. Around 2029 it is near forty-seven days. Short-lived profiles run about six days. A dashed marker shows renewal starting thirty days before the end of the first bar.Todaypublic maximum90 daysrenew with 30 days leftAround 2029public maximum47 daysShort-livedoptional profileabout 6 daysDrawn to scale. Renewal has to start long before the bar runs out.
Figure 9.4. Lifetimes shrink in steps, so renewal has to be automatic. No calendar reminder survives 47 days.

Renewal starts well before expiry. Certbot tries again when about thirty days remain, and its timer runs twice a day, so one failed attempt has many chances to recover. Caddy renews on its own schedule and needs no timer you have to remember. Both fail in the same handful of ways: a firewall change closes port 80, a DNS record drifts, the disk fills, or the process holding the certificate never picks up the new file.

That last failure is the sneaky one. Certbot writes new files under /etc/letsencrypt/live, but nginx reads its certificate at startup and on reload. The renewal reports success, and the site keeps serving the old certificate until the old one actually dies. A deploy hook, a small script Certbot runs after each successful renewal, closes that gap. Put the reload in the hook, then test the whole path before you need it rather than trusting that it works.

Renewals also fail quietly, which is why you should watch expiry from outside the server. A monitor on the public internet should tell you when the certificate a visitor sees has fewer than fourteen days left. A monitor on the same box dies with the box. Chapter 19 builds that alarm properly.

Every name on a certificate is a promise: this key speaks for these hostnames. You get to choose the shape of that promise.

A per-name certificate lists exactly the hostnames you need. app.pipeslab.in gets its own certificate, and api.pipeslab.in gets another. HTTP-01 handles both happily. If one key leaks, the damage is one name, and nobody outside the server needs a DNS credential. The cost is the count. Ten names mean ten renewals and ten places a reload can quietly fail.

A wildcard certificate covers *.pipeslab.in, every first-level name under the domain, with one file and one renewal. The price is how ACME issues it. Wildcards come only through DNS-01, which means proving you control the zone by writing a record through your DNS provider’s API. That credential is powerful. Whoever holds it can change any record in the zone, including the one that points app somewhere hostile. A wildcard key on five servers also means five servers can answer for every name under the domain.

For a small production VPS, my advice is per-name certificates for your few public hostnames. Reach for a wildcard when you have many internal names behind one proxy and you can keep the DNS token tight. Chapter 10 explains the DNS side, Chapter 11 the domain itself, and Chapter 12 the subdomains that make wildcards tempting.

Certificate transparency logs add a wrinkle. Publicly trusted certificates are written to public logs, names included. A per-name certificate for admin.pipeslab.in announces that the name exists. A wildcard shows only *.pipeslab.in. Do not lean on that for secrecy, though. Attackers find names in many other ways.

A certificate proves who you are. It does not stop a visitor from typing http:// first, and that first plain request is where someone on a bad café Wi-Fi gets to play you. HTTP Strict Transport Security closes that door. Your server sends a header, Strict-Transport-Security, that says: for the next so many seconds, use HTTPS for this host, and never offer plain HTTP. The browser remembers, and from then on it upgrades the request itself.

The max-age value sets how long the memory lasts. includeSubDomains extends the promise to every name below yours. Start small, with a day, then weeks, then a year, once you are sure everything under the name really speaks HTTPS. A long max-age set too early locks a name out for its full length, even after you fix the problem.

The preload list is the next step. Browser vendors ship a list of domains that get HSTS before any visit, so even the very first request is HTTPS. To join, you serve the header with the preload directive and submit the domain. Removal is slow because it rides on browser releases. Preload only when every name under the domain works on HTTPS, and expects to keep it that way.

Two top-level domains are on the preload list as whole TLDs: .dev and .app. Browsers treat every name under them as HTTPS-only and do not attempt plain HTTP at all. If you have ever typed http:// at a .dev site and watched it fail instantly, this is why. The lab placeholder pipeslab.in is not on the list, but a lab name on .dev would be HTTPS from its first day.

The root that expired on a Thursday. Let’s Encrypt’s early certificates were issued through a chain that ended at a root owned by IdenTrust, called DST Root CA X3. Let’s Encrypt had its own root, but browsers and operating systems took time to trust it, so the early chains were cross-signed to reach the older, widely trusted root. That root expired on 30 September 2021. Clients that trusted only that old path, including some older Android phones and devices running old OpenSSL 1.0.x builds, suddenly failed to verify certificates that were perfectly good. For most sites, nothing on the server had to change. Let’s Encrypt changed its default chain, and clients that could follow the new path recovered. The lesson is that a chain is a path, and every link has a date.

The certificate nobody owned. Here is a composite, not a single incident. A team’s internal status page lives on a hostname that the current team never set up. The certificate came from a vendor’s demo, its renewal went to an email nobody reads, and it expires at four in the morning on a Sunday. Nothing on the public site breaks. Monday morning, the on-call engineer finds that the tool in the dashboard is red, the vendor’s support queue is closed for the weekend, and the fix takes twenty minutes once someone finds the right login. The fix was never hard. The ownership was.

A widely told story from early 2020 links an expired certificate to a Microsoft Teams outage, and another from late 2018 ties one to a mobile network outage involving O2 in the UK and SoftBank in Japan, if memory serves. Treat the details as approximate. The shape is the lesson: a certificate nobody was tracking, inside a system large enough that expiry became an emergency.

Put Cloudflare in front and you no longer have one TLS connection. You have two. The visitor talks TLS to Cloudflare, and Cloudflare opens a second connection to your origin. The SSL/TLS mode in the dashboard decides what that second hop looks like, and most of the confusing outages around Cloudflare come from the two halves disagreeing.

  • Flexible. Visitor to Cloudflare is HTTPS. Cloudflare to your origin is plain HTTP on port 80. No certificate needed on the origin, which is why Flexible tempts people.
  • Full. Both halves are encrypted. Cloudflare accepts whatever certificate the origin shows, even a self-signed one, without checking it.
  • Full (strict). Both halves are encrypted, and the origin certificate must be valid and match the name. This is the one we recommend.

Here is the classic. Your app, or nginx in front of it, says “if the request is not HTTPS, send it to HTTPS.” Cloudflare hands the origin plain HTTP, so the origin obeys its rule and redirects. Cloudflare passes the redirect back. The browser follows it, arrives over HTTPS, Cloudflare forwards plain HTTP again, and the origin redirects again. Every box did its job correctly, and the browser gives up after roughly twenty hops with a “too many redirects” error.

Flexible mode redirect loopThree lifelines: visitor, Cloudflare and origin. The visitor asks over HTTPS. Cloudflare sends plain HTTP to the origin, which redirects to HTTPS. Cloudflare passes the redirect back, and steps 4 to 7 repeat.VisitorCloudflareOrigin1 GET https://pipeslab.in2 GET http:// (Flexible)3 301 to https://4 301 to https://5 GET https://6 GET http://7 301 to https://Steps 4 to 7 repeat until the browser gives up
Figure 9.5. The Flexible-mode loop. Each box follows its own rule, and together they never stop.

The fix has two honest options. You can switch to Full (strict), so the origin receives HTTPS and its rule is satisfied. Or you can teach the origin to trust the header Cloudflare sends to say what the visitor originally used. That works, but now your app’s correctness depends on a header someone has to keep trusting. Pick Full (strict). It removes the question.

Full (strict) needs a certificate on your server that the connection can check. A Let’s Encrypt certificate does the job, and it is the right choice if your server is reachable on port 80 or you have DNS API access. The other option is a Cloudflare origin certificate. Cloudflare issues it from its own internal authority, for free, with a lifetime measured in years rather than ninety days. If memory serves, the longest option is around fifteen years.

Browsers do not trust it. Only Cloudflare does. So an origin certificate is useful only when traffic really flows through Cloudflare, and a visitor who reaches your IP directly sees a certificate warning. That is the point. Pair it with a firewall rule that accepts port 443 only from Cloudflare’s published address ranges, and the doorman becomes the only way in. Chapters 14 and 17 take that further.

Wildcards for DNS-01 come back in Chapters 10 and 11, where the DNS API lives.

Goal. Get a real, trusted certificate for a name that points at the lab VPS at 203.0.113.10, then learn to read it, renew it, and break it on purpose.

Conceptual steps.

  1. Give the lab a name. If pipeslab.in is not pointed at the lab until Chapter 10, use a wildcard-DNS service that embeds the IP in the name. Those services are shared by many people, and certificate authorities rate-limit by name, so expect occasional trouble. That is one more reason to start with the staging environment.
  2. Choose your receptionist. Either let Caddy handle the whole cycle, or run nginx with Certbot and a deploy hook that reloads nginx after each renewal.
  3. Inspect the chain. Ask the lab what it presents for that name. Find the leaf, the intermediate, and the expiry date, and check that the leaf names the domain you asked for.
  4. Dry-run the renewal. Ask the renewal machinery to do everything except replace the real certificate. It should report success without changing anything.
  5. Break it on purpose. Close port 80 at the cloud firewall and ask for a new certificate with HTTP-01. Watch it fail, read the error, then reopen the port.
  6. Compare two names. Point a second name at the same IP and confirm each one gets its own certificate. That is SNI, working on your own box.

How you’ll know it worked. The browser shows a padlock with no warning. The chain output shows a leaf plus an intermediate, and the expiry date is about ninety days out. The dry run reports success. With port 80 closed, the challenge fails with a connection error that names the port, and reopening the port fixes it. If the failure message surprises you, you have just learned what the proxy in Chapter 8 was quietly doing for you.

You started this chapter with a padlock that expired on a Sunday. You now have the operator’s view of it, which is the view that decides whether your site stays up.

  • A certificate is a signed statement that binds a name to a public key. The browser checks the chain from leaf to intermediate to a root it already trusts, along with the name and the dates.
  • Your server holds the private key. The certificate is public. Lose the key and you rotate; leak it and you revoke.
  • SNI lets one IP address answer for many names, because the hostname travels in the first message of the handshake.
  • ACME automates the proof of ownership. HTTP-01 needs port 80 reachable, DNS-01 needs DNS API access and is the only route to wildcards, and TLS-ALPN-01 works on port 443.
  • Short lifetimes are a feature. They force automation, and automation is what keeps expiry from becoming a 2 a.m. call.
  • HSTS tells browsers to refuse plain HTTP for your name. Preload puts that promise in the browser before the first visit. .dev and .app are preloaded, so HTTPS is mandatory there.
  • Behind Cloudflare, run Full (strict). Flexible loops when the origin forces HTTPS.

Well done. You can now read a certificate chain, explain why a renewal is a feature, and tell a Flexible loop from a healthy Full (strict) setup. That is most of the TLS you will ever need to operate.

1. What does a browser check when it receives your certificate, and what does your server keep secret?

The browser checks that the leaf certificate’s signature chains through an intermediate to a root it already trusts, that the name matches the one it asked for, and that the dates are valid. Your server keeps the private key secret. The certificate itself is public.

2. How can one IP address serve many HTTPS sites?

Through SNI. The client sends the hostname in the first TLS message, the ClientHello, so the server can pick the right certificate before the encrypted session begins.

3. When would you choose DNS-01 over HTTP-01?

When port 80 is closed or not reachable from the internet, when the server is internal, or when you need a wildcard certificate. DNS-01 requires API access to your DNS provider.

4. Why does Flexible mode loop forever with an origin that forces HTTPS?

The visitor reaches Cloudflare over HTTPS, but Cloudflare talks to the origin over plain HTTP. The origin redirects to HTTPS, Cloudflare sends that request back over HTTP, and the origin redirects again. Each hop looks like a fresh request, so the loop never ends.

5. What does HSTS preload do that the HSTS header alone does not?

The HSTS header only protects you after the browser has seen it once over HTTPS. Preloading ships your domain inside the browser’s built-in list, so even the first visit is protected.

Warm-up 1. Name the chain. List the three certificates in a typical chain, from the one your server presents to the one that is trusted by default.

Answer

Leaf (your certificate for the name), intermediate (the CA’s signing certificate), and root (the anchor the browser or operating system already trusts). Your server sends the leaf and the intermediate. The root lives in the trust store.

Warm-up 2. Why short? In two sentences, explain why a 90-day certificate is safer than a 3-year one, even though it renews more often.

Answer

A short lifetime means a leaked or misissued certificate expires soon, and a renewal bug shows up in weeks rather than years. Frequent renewal is cheap only because it is automated, so the short lifetime pushes you toward the automation that you should have anyway.

Warm-up 3. The right mode. Your origin is a VPS with a valid certificate, and Cloudflare sits in front. Which SSL mode do you pick, and why?

Answer

Full (strict). Cloudflare encrypts to the origin and checks that the origin certificate is valid for the name. Flexible hides the origin’s certificate problems and causes loops, and plain Full accepts any certificate, which defeats the check.

Lab 4. Read the chain. On the lab VPS, use openssl s_client to see the certificates your server presents for one name.

Hint and model solution

Hint: Connect to 203.0.113.10 on port 443 and pass the name with -servername, then look for the chain depth lines and the final verify result. Pipe the output through a filter to read just the certificate subjects and the verify return code.

Model solution: You should see at least two certificates in the chain, a leaf whose subject matches your name and an intermediate issued by a CA. The verify return code should read 0 when the chain is complete. A nonzero return code means the server is not sending the intermediate, or the name does not match.

Lab 5. Dry-run the renewal. Ask the ACME client to rehearse a renewal without changing your real certificate.

Hint and model solution

Hint: With certbot, use its renewal command with the dry-run flag. With Caddy, check its logs for the automation lines and confirm the certificate’s expiry date with the same openssl check as exercise 4.

Model solution: The dry run should report a successful simulated renewal against the staging environment, and the real certificate’s expiry date should be unchanged. Confirming that the expiry date did not move proves the rehearsal touched nothing live.

Lab 6. Break HTTP-01 on purpose. Close port 80 on the lab VPS for a moment, then request a certificate using HTTP-01, and watch the challenge fail.

Hint and model solution

Hint: Block port 80 with the firewall, run the certificate request in its HTTP-01 mode, and read the error. Reopen port 80 afterward and check that the firewall rule is removed, because the lab’s guard must be restored.

Model solution: The client should report that the challenge could not be validated, with a connection or timeout error. The Let’s Encrypt side cannot reach port 80 to fetch the token file. The lesson is that HTTP-01 is a question about reachability, and the answer is only as good as your firewall.

Staff 7. Forty domains, one calendar. You run forty domains across three VPS hosts. Describe the renewal monitoring you would put in place, and what would page someone.

Model answer

Automate renewal on every host and treat automation as the first line, not the only one. Add an external check that reads the expiry date of every public name from outside your network, once a day. Alert at 21 days remaining and page at 7. Monitor the renewal logs too, because a renewal that fails silently looks the same as success until the last week. Keep one inventory of names, so a new subdomain cannot escape the check.

Staff 8. Locking the origin. Your origin is behind Cloudflare, and someone found the origin IP. What do you change, and what does that buy you?

Model answer

Restrict port 443 on the origin firewall to Cloudflare’s published address ranges, so only the doorman can knock. Keep Full (strict) so the origin certificate is checked as well. This does not replace the certificate, but it removes the direct path that bypasses Cloudflare’s filtering. Expect doorknob rattlers to keep trying; that is weather, not a personal attack.

Book 2 of a series. Book 1: The Glue.