Skip to content

17. Cloudflare: Proxy, Shield and Tunnels

“The best guard is the one standing a continent away from your door.”

At 2 a.m. on a Tuesday, Priya’s phone lights up. It is Rohan, who runs operations for her dance academy, and his message is short: “Booking page is dead. Students are asking in the group chat.”

She tries the page on her own phone. It spins. Her ₹12,000 phone is on a mobile tower in Kothrud that is having a difficult night, so she tries it on her laptop over home wifi. It spins there too. Then she SSHs into the VPS, and she gets the moment every operator knows. The box answers, the prompt appears, and the relief is short-lived. The load average is high. The access log is a wall of requests from thousands of different addresses, asking for /wp-login.php, /.env, /admin and other things her app has never served. Some of those requests are polite. Most are not.

Nothing is broken, exactly. Her server is being rattled. Somewhere a bot is walking down the street trying every door handle to see what opens, and a second bot is doing the same a minute later, and so on forever. These are doorknob-rattlers. They are weather, not personal. Every public server gets them. Yours just got a cold front.

Meera, who runs a studio in Bengaluru and has survived more of these nights than she would like, texts back in four seconds: “Put Cloudflare in front. Turn on the orange cloud. Ten minutes.”

Priya has read the words “proxy” and “shield” on marketing pages and has a vague sense of what they mean. She does not have a clear sense of what they do to her traffic, and under that sits a worse question. If a company now stands between the internet and her server, what exactly is behind it, and can anyone still walk up to the back door?

This chapter is for that question. The short answer is that Cloudflare can take most of the rattling off your hands, hide where your server actually lives, and, with a feature called Tunnel, let you stop opening doors to the street altogether. The longer answer has leaks, limits and one war story that every operator should know. You get all of it.

(Priya, Rohan and Meera are composites, and so is the log. The night is one that thousands of operators have had.)

Everything that works on localhost is cursed in exactly this way: it has never met a stranger. The rest of this chapter is about the strangers.

Start with the city directory. When someone types your name into a browser, the first stop is DNS, the directory that turns a name into an address. We covered it in Chapter 10. Without Cloudflare, the answer is your server’s address. With Cloudflare in front, the answer is one of Cloudflare’s own addresses.

That address is not in one place. Cloudflare announces the same addresses from many data centres around the world, and the internet’s routing sends each visitor’s packets to the nearest one. This is called anycast. It is why a visitor in Pune and a visitor in Frankfurt can both reach a building a short walk away, while your VPS sits in one city. The collection of those buildings is the edge.

Each DNS record in Cloudflare’s dashboard has a small cloud beside it, and the colour of that cloud decides what happens next.

An orange cloud means proxied. The record resolves to the edge. The visitor’s connection ends at Cloudflare, Cloudflare reads the request, decides what to do with it, and then opens its own connection to your server to fetch the answer. That is two connections and two decisions, and your server only ever talks to Cloudflare.

A grey cloud means DNS-only. The record resolves to your real address and Cloudflare steps out of the path. It still answers the directory question, and that is all it does. Your server is visible and reachable directly, exactly as it was before you signed up.

Proxied and DNS-only paths to one serverVisitors reach a Cloudflare edge box before the server when the record is proxied. A dashed path shows DNS-only traffic going straight to the server’s real address.Visitorsthe internetCloudflare edgenearest city, anycastcache, WAF, DDoSbot checks, rate limitsYour server203.0.113.10DNS-only (grey cloud): straight to the server IPProxied (orange cloud): the answer is the edge address
Figure 17.1. Orange cloud: visitors meet the edge first. Grey cloud: they go straight to your server's address.

The two-connection shape matters for security. The certificate your visitor’s browser checks is the edge’s certificate for your domain. The second connection, from Cloudflare to your server, has its own certificate rules, and those are the SSL modes from Chapter 9. Read that section before you switch the cloud on. The default mode is not always the one you want.

This is why Priya’s night could end without a single change to her app. Once the orange cloud was on, the doorknob-rattlers met the doorman first. Most of them never got past him. The rest of this chapter is about what they could still find, and what you can do about that.

Proxying hides your origin address from the ordinary visitor. Anyone who types your name into a browser, or runs a directory lookup, sees the edge. That is a real gain, and it is usually what people mean when they say “hide my server.”

Hidden is not the same as secret, though. Your server’s real address is still written down in several places, and a patient person or a patient bot can find it. The useful way to think about this is to ask where your address has ever been recorded. Here are the usual answers.

Five leaks that reveal the origin addressFive sources on the left, each with an arrow to the origin server on the right: passive DNS history, unproxied records, outbound calls and mail headers, certificate transparency logs, and IPv4 scans that send the site’s Host header.Passive DNS historyMX and other unproxied recordsOutbound calls, mail headersCertificate transparency logsIPv4 scans sending your HostYour origin203.0.113.10
Figure 17.2. Five ways your real address leaks around the shield, and each arrow is a leak until you close it.

Old DNS history. Passive DNS services record which names pointed at which addresses over time. If your domain pointed at your VPS for a year before you moved behind the orange cloud, that history usually survives. You cannot unpublish it. The only real cure is to move the server to a new address once it is proxied, and to keep the old address quiet.

Unproxied records. Cloudflare proxies web traffic, meaning HTTP and HTTPS. Mail records are never proxied, because mail servers speak SMTP, which the edge does not handle. So if your MX record points at a host on the same box, or at the same address, your server’s address is in public DNS by design. The same goes for any grey-cloud subdomain. A forgotten dev or ftp record pointing at the VPS is a free clue for anyone who looks. Email records are covered in Chapter 13.

Outbound calls. Your server talks too. When it calls a third-party API, sends email, or fetches a file from a remote host, the other side sees your real address. Mail headers can carry a trail of the servers that handled a message, and that trail can name your origin in a place you never thought to protect. Treat anything your server sends out as a letter with a return address on it.

Certificate transparency logs. Certificate authorities publish the certificates they issue to public logs, so that anyone can audit them. Those logs list hostnames. If you got a certificate for origin.pipeslab.in, or for any grey-cloud name, that name is now in a public list, and scanners read those lists constantly.

IPv4 scans. Scanners sweep the whole IPv4 space, which is around four billion addresses. Send the right Host header to each one and the server that answers with your site announces itself. A determined scanner on a cheap connection can do that in days. It is not aimed at you. It is weather, the same weather as the rattling at the start of this chapter, and it finds the box whether or not anyone interesting lives there.

Hiding the door is half the job. The other half is making the door refuse anyone who did not come through the doorman. Until you do that, every leak in the last section still works. A scanner that found your address can skip Cloudflare entirely, knock on the back door and ask for your site by name.

There are three ways to lock it, and they are not equal.

The allowlist. Cloudflare publishes the ranges of addresses its edge uses for proxied traffic. You tell your firewall to accept web traffic on ports 80 and 443 only from those ranges, and to drop everything else. The guard now has a clipboard with Cloudflare’s addresses on it. Most people reach for this first, and it is a good first step.

Its weakness is the one that matters. Those ranges are shared by every Cloudflare customer. The allowlist proves that a request came from Cloudflare. It does not prove that it came from your Cloudflare account. It keeps out the scanners, which are most of the weather, but it does not keep out a determined neighbour who has worked out how to send traffic through the edge toward your address.

Authenticated Origin Pulls. Here Cloudflare presents a client certificate when it connects to your server, and your server checks that certificate before it answers. A request without the right certificate is turned away during the TLS handshake. This is a stronger check, because it ties the connection to your zone rather than to a range shared by thousands of customers. The cost is more setup at the origin, a certificate to keep current, and comfort with mutual TLS, which we touched on in Chapter 9.

The tunnel. The third option is the one this chapter builds toward. If your origin does not listen on a public port at all, there is no door to lock.

Allowlisting Cloudflare ranges at the origin firewallVisitors reach the Cloudflare edge, which passes traffic through a firewall guard to the server. A scanner that tries the server directly is stopped at the firewall with a red cross.Visitorsthe internetCloudflare edgeCloudflare’s own rangesshared by every customerfirewall: Cloudflare onlyYour server203.0.113.10ports 80 and 443 allowlistedScannersends your Host headerdroppedAllowlist the ranges, and let the default policy be drop.
Figure 17.3. The allowlist: only the edge may knock, and the firewall drops everyone else.

The allowlist has a trap that catches people who did everything else right. It covers the ports you name, usually 80 and 443. A dev server on port 3000 that listens on every address, or an admin page on 8080 that someone forgot about, is still a side window. The fix is to bind internal services to localhost and to make the firewall’s default policy drop. Mail on port 25 needs its own decision, which Chapter 13 makes.

Once the orange cloud is on, the edge does more than hide your address. It runs a stack of checks, and each one asks a different question about the visitor.

The first is the cache. Images, stylesheets, scripts and anything marked cacheable get a copy stored close to the visitor, so your server only sees the requests the cache could not answer. That is the classic CDN bargain, and Book 1’s hosting and caching chapter tells the longer version. The second is the WAF, the web application firewall. Its rules read the request itself and refuse the ones that look like SQL injection, path traversal or a known exploit probe. The third is rate limiting, which counts requests per visitor per window and starts answering 429 when someone hammers your login route. The fourth is bot management, which scores traffic on behaviour and known-bad fingerprints. The fifth is DDoS protection, and it is mostly a property of size. The edge has far more capacity than your VPS will ever have, so a flood gets soaked up out there rather than at your door.

Page rules and redirects sit alongside these. Sending www to the bare domain, or forcing HTTPS, can happen at the edge before your app wakes up. Chapter 9 covers the SSL modes, which decide whether the edge talks to your origin encrypted. Read that before you touch the dropdown, because “Flexible” and “Full (strict)” fail in very different ways.

Services stacked at the Cloudflare edgeA visitor enters the Cloudflare edge, which holds a cache, a WAF, rate limiting and bot checks. Only traffic that passes reaches the origin server, which accepts calls only from the edge.VisitoranywhereCloudflare edgeCachestatic filesWAFbad requestsRate limitper visitorBot checkscripts and botsOriginlockedOnly what passes the checks reaches your origin.
Figure 17.4. The edge runs its checks before your server wakes up. Bad traffic should stop at the first wall it meets.

The catch is that every check is only as good as its rules. A rule you have never tested is a rule you do not have yet. Turn on one service at a time, watch the analytics and the firewall events for a day, and only then add the next. Plan names and feature tiers change, so check the current dashboard before you promise a client a feature.

Everything above assumes your origin has a public address the edge can reach, with a firewall letting the edge in. On a VPS with a static address, that is fine. On a machine in your flat in Pune, behind a home router, it is often impossible. Chapter 1 explained CGNAT: your provider shares one public address among many homes, so no connection from the internet can start at your router, however many ports you forward.

Yet the same machine can call out to anywhere. Tunnels run on that asymmetry. Cloudflare Tunnel runs a small program, cloudflared, on your server. It dials out to Cloudflare and opens several connections to several nearby edge locations, encrypted, over QUIC where it can and HTTP/2 as a fallback. The exact protocol list changes between releases, so treat the current docs as the authority. Once those connections are up, Cloudflare sends requests down them. Your router never receives an unsolicited packet, so you open zero inbound ports.

An outbound connection is the one kind your NAT already understands. The replies ride back down the connection you opened, and the gate guard logs it like any other departure. That is why the trick works from a home machine, and why it works even when the ISP gives you no public address at all.

Dialling out solves reachability. The next question is how the doorman knows which corridor leads where.

The answer is a list of ingress rules. Each rule says: requests for this hostname go to this local service. staging.pipeslab.in goes to the app on port 3003 on the same machine, and app.pipeslab.in goes to the main app. The final rule is a catch-all that answers 404 to any name you did not claim. That last one matters more than it looks, because a scanner rattling a hostname you never published gets nothing useful back.

The rules can live in the Cloudflare dashboard or in a local file, depending on how you set the tunnel up. Each hostname also gets a DNS record that points at the tunnel and is proxied. Those names belong to the directory you met in Chapter 10, and your home address appears nowhere in them. Anyone who looks up staging.pipeslab.in learns about Cloudflare, not about your flat.

The localhost in a rule is local to the machine running cloudflared. Port 3003 never faces the internet, because nothing outside can reach that machine’s ports to begin with. The only way in is the connection the tunnel opened.

This is my pick for a home-hosted staging box, and a good addition for a production VPS that already has a static address. The real win is that the origin lock stops being a firewall rule you can get wrong. With no inbound port, there is no rule to get wrong, because there is no door.

Cloudflare Tunnel pathA visitor sends a request to the Cloudflare edge. The home server’s cloudflared program has already dialled out to the edge, and traffic flows back down that encrypted connection to the app. The home router has no inbound ports open.Visitorany networkCloudflare edgemany nearby sitesDoorman rulesWAF, cache, AccessYour servercloudflaredapp :3003requestdials outtraffic downrouter: no inbound portsEvery connection that matters was started from inside, so the gate never opens.
Figure 17.5. The server dials out, so visitor traffic comes back down a connection that already exists.

Three tools look alike from a distance, and they are not the same thing.

  • ngrok is a sharing tool. An agent on your laptop gives you a public address that points at localhost. It is superb for a ten-minute demo or for catching webhooks while you develop. It was built to share a running thing, not to run one. Stable names are a paid feature on the plans I have seen, so check the current pricing.
  • Tailscale Funnel, from Chapter 16, publishes a tailnet service to the open internet through Tailscale’s relays. It is the simplest of the three, and its names sit under your tailnet’s domain. It suits something you already reach privately and occasionally want an outsider to see.
  • Cloudflare Tunnel serves production traffic on your own domain, with the WAF, caching and Access in front of the connection. It takes more setup than either, and that setup is the price of owning the front door.

Some things should be reachable but never public: an admin panel, a staging site with an unfinished feature, a dashboard your team uses. The old answer was a login built into each app, or an IP allowlist that breaks every time your ISP reshuffles addresses.

Access moves the login to the edge. A visitor who is not signed in gets a sign-in page, enters an email address, and receives a one-time code. Pass that, and the request continues to the tunnel or origin. The app never sees a password, and it may never know a gate existed. Policies such as “anyone at my company’s domain” or “these three addresses” live in the dashboard, so you can add a teammate without a deploy. Login methods and plan limits change, so check what your plan offers today.

Access belongs to Zero Trust, Cloudflare’s umbrella for identity-first products. The principle is that being on the right network proves nothing. Each request has to show who it is. Your tailnet’s ACLs work the same way for your private machines, and Access does it for a public hostname.

Pair it with the origin lock. If someone finds the origin IP through one of the leaks we covered, Access does nothing for them unless the request also goes through the edge or the tunnel. Tunnel plus Access gives an admin tool nothing listening on the internet and a login in front of every request. That is the setup I would ship for an internal tool tomorrow.

Every good tool has a price, and Cloudflare’s is written in the small print. These are the ones that bite people I have worked with. Check current figures before you design around them, because plan limits move.

Upload size. On the free and Pro plans, a request body is capped at roughly 100 MB. If your dance-academy app takes video uploads from teachers, that cap is the wall you will hit, and the error comes from the edge, not from your app. The fix is architectural. Send big files straight to object storage with a signed URL, and keep only the metadata in your own app.

Long responses. The origin gets about 100 seconds to start answering. Stay silent longer and the edge gives up, and the visitor sees a 524. A report that takes three minutes is a background job wearing a request’s clothes. Make it a job, return quickly, and let the page poll or hear the result when it is ready.

WebSockets and long-lived connections. They pass through the proxy, and live dashboards and chat use them happily. The thing to watch is the idle timeout and the reconnect logic. Those are your job, not the edge’s. Assume every socket will die once a day and write the client so it comes back on its own.

Caching surprises. By default the edge caches static file types such as images, CSS and JavaScript, not HTML. The moment you write a rule that caches HTML, you own its consequences. Two classic ones: a deploy goes out and the old page keeps appearing until its time-to-live runs out, and a rule caches a logged-in page so the next visitor sees somebody else’s dashboard. Purge deliberately, and never cache a path that depends on who is asking.

Vendor dependency. Your DNS, your public TLS, your login page and your shield now run through one company. For most small production setups that is a fair trade. It still deserves a line in your runbook, with an answer to the question “what do we do when the doorman is gone?” The war stories below are where that answer comes from.

The 52x family. When the edge cannot get a good answer from your origin, it speaks in codes from the 520 to 526 range. From memory, and roughly: 520 means the origin returned something malformed or unknown. 521 means the origin refused the connection, so your app is down or the firewall is blocking the edge. 522 and 523 mean the connection never got established or the origin was unreachable. 524 means the origin connected but stayed silent past the limit. 525 and 526 are trouble in the TLS handshake between the edge and your origin. The rule of thumb: a 521 means the door is shut, and a 524 means someone is inside and slow. Read the code before you blame your code.

Cloudflare has had bad days, and they teach better than any feature list. The three below are widely told stories, and I have hedged the details because I am working from memory. Read the vendor’s own post-mortems before you quote a number in a meeting.

Back in July 2019, a web application firewall rule with a poorly written regular expression backtracked badly on certain inputs. Once that rule was deployed, CPUs across the edge were pegged for roughly half an hour, and a large slice of the internet felt it. The lesson is that a regular expression is code, and a firewall rule is a production change. It needs a canary, a staged rollout and a rollback button.

In June 2022, a network configuration change pushed across roughly nineteen data centres disrupted traffic for a while. The person who made the change saw nothing alarming in it. The lesson is that the network carrying your packets is also managed by configuration, and configuration is a deploy with a blast radius.

On or around 18 November 2025, a widely told story says the file that feeds the bot-management system grew past the size the proxies expected. Proxies around the world crashed and restarted for hours. The lesson is that generated configuration is code too. Validate its size and shape before it reaches the fleet, and assume the generator will one day produce something nobody imagined.

The common lesson is blunt. Your shield is also a single point of failure. The doorman who keeps the rattlers out can, on a bad morning, lock out the people you want inside. You do not fix this by removing the doorman. You plan the way out before you need it:

  • Know how to switch a record to grey cloud, so traffic goes straight to the origin. Remember that a locked origin will refuse those requests, so the break-glass plan has to say which firewall rule you loosen, and for how long.
  • Keep the TTLs on records you might need to move short enough that a switch takes minutes, not hours.
  • Host your status page somewhere other than Cloudflare, so you can tell users what is happening while the doorman is down.
  • Keep an operator path that does not depend on the edge at all. A tailnet address for the server, from Chapter 16, is a good example.

The lab: a staging site behind the doorman, with no open door

Section titled “The lab: a staging site behind the doorman, with no open door”

Goal. Put the staging hostname of the lab domain behind Cloudflare, serve the tiny hello-pipes app on the lab VPS through a Tunnel, and put a login in front of it. At the end, the lab VPS should have no new inbound ports, and a stranger should find nothing useful at that hostname.

Conceptual steps.

  1. Move the lab zone’s DNS onto Cloudflare. Check that the apex and the subdomain records look the way Chapter 10 taught you, and that nothing important was lost in the move.
  2. Proxy the app hostname with the orange cloud. From outside, confirm that the answers now come from Cloudflare’s addresses, not from the lab’s public IP.
  3. Make the app read the real visitor address from the header Cloudflare adds. Think about who can forge that header. It is safe to trust only when the origin accepts traffic from Cloudflare alone, which is the origin lock from earlier in this chapter.
  4. Create a Tunnel that maps the staging hostname to the local port where hello-pipes listens. Run the connector on the lab VPS and check that it dials out, not in.
  5. Add an Access policy to the staging hostname that lets only your own email address through, with a one-time code.
  6. Scan the lab from the outside, and then check that the origin’s public address shows nothing for the staging path.

How you’ll know it worked.

  • From outside, the proxied names resolve to Cloudflare, and the bare lab address does not answer for the staging hostname.
  • The app’s log shows your home connection’s address as the visitor, not a Cloudflare address, because the header is being read and trusted only correctly.
  • In a private browser window, the staging URL asks for an email code before it shows anything. A second browser with no code gets the same wall.
  • The Tunnel shows as healthy in the dashboard, and an outside port scan finds no new open port on the lab VPS.
  • When you stop the local app, the staging hostname returns a Cloudflare error page, and the 52x code tells you which door is closed.

If all five hold, you have built the pattern the rest of this book keeps returning to: an app that listens only inside, a corridor dug outward, and a badge check at the door.

A proxied name means the doorman answers first, and the address in public DNS belongs to the doorman, not to your server. Proxying hides your origin only while the origin stays hidden. Old DNS records, an unproxied mail host on the same IP, outbound calls from the server and certificate transparency logs can all give it away.

The origin has to refuse everyone except the doorman. You can do that with a firewall allowlist, with Authenticated Origin Pulls, or with a Tunnel that opens no inbound port at all. A Tunnel dials out from your machine, which is why a home server in Pune can host a staging site behind CGNAT. Access puts a login at the door without touching the app. And because the shield is also a single point of failure, you keep a break-glass path that does not run through Cloudflare.

That is a lot of door-and-doorman thinking for one chapter. Well done.

1. A name is proxied (orange cloud). What address does the public internet get when it resolves that name?

Cloudflare edge addresses, not your origin’s IP. Your server’s address stays out of the public answer.

2. Why can proxying still leak your origin IP?

Because the same IP may appear elsewhere: in old DNS history, in an MX or other unproxied record, in outbound requests that carry it, or in certificate transparency logs that name an unproxied hostname.

3. How does an allowlist differ from Authenticated Origin Pulls?

The allowlist checks the source address against Cloudflare’s published ranges. Authenticated Origin Pulls checks a client certificate, which proves the request came from Cloudflare and not from someone who only sends a matching address.

4. Why does a Tunnel work behind CGNAT with no port forwarding?

Because cloudflared makes the outbound connection. Replies return over that connection, which is already open, so nothing needs to come in from the street.

5. What does a 524 tell you, and where is the likely fault?

The edge reached your origin, but the origin did not respond in time, roughly within the 100 second window on the usual plans. The fault is usually the app or the database behind it.

6. What does Access cost the app, and what does it cost you?

The app needs no change, because the identity check happens at the edge. The cost is a dependency: if the identity check or Cloudflare itself fails, the admin path fails with it, so keep a second way in.

Warm-up 1. Read the orange cloud. A colleague says the server is hidden because it sits behind Cloudflare. Name two ways its IP could still be found, and one check for each.

Answer

Any two of: an old A record in passive DNS history, an unproxied mail host on the same IP, the server’s outbound webhooks or email headers, and a certificate transparency entry for an unproxied hostname. Check history for old records, list the zone for grey-cloud records on that IP, and inspect the headers of a test email.

Warm-up 2. Explain CGNAT in one breath. Why can’t a friend in another city open a port on your home machine in Pune, and why does a Tunnel still work?

Answer

Your connection shares one public address with many neighbours through carrier-grade NAT, so inbound traffic has no address of yours to target. A Tunnel works because cloudflared dials out, and replies come back over the connection it already holds.

Warm-up 3. Name the three origin locks. For each, say what it proves and what it costs you.

Answer

An allowlist of Cloudflare ranges proves the source address belongs to Cloudflare, and costs you a list to keep current. Authenticated Origin Pulls proves the client certificate is Cloudflare’s, and costs you certificate handling. A Tunnel opens no inbound port at all, and costs you running cloudflared as a service.

Lab 4. Map a hostname to a local app. Send staging.pipeslab.in through a Tunnel to the hello-pipes app on port 3003, and confirm the lab VPS has no new public listener.

Hint and model solution

Hint: create the tunnel in the Zero Trust dashboard, add a public hostname for staging.pipeslab.in pointing at http://localhost:3003, then compare ss -tlnp before and after. Model solution: the app still listens on 127.0.0.1:3003, and the only new activity is cloudflared’s outbound connections.

Lab 5. Restore the real client IP. Your app logs only Cloudflare addresses. Make it log the visitor’s IP from CF-Connecting-IP, and explain when that header can be trusted.

Hint and model solution

Hint: read the header in the app and log it next to the socket address, then request the site through the proxy. Model solution: prefer CF-Connecting-IP only when the request came from Cloudflare. Trust is safe only when the origin accepts Cloudflare traffic alone; otherwise anyone can send the header and fake a visitor’s IP.

Lab 6. Put a login at the door. Protect the staging hostname with Access and a one-time email code, then check that an outside scan of the origin shows nothing for that path.

Hint and model solution

Hint: create a self-hosted Access application for staging.pipeslab.in, allow your own email, and test in a private window. Scan the origin from outside with nmap on ports 80 and 443. Model solution: the hostname asks for the email code, and a direct scan finds no open path for it, because the tunnel opens no inbound port.

Staff 7. Design the break-glass plan. The shield went dark for two hours during an incident. Name the three things you would have prepared beforehand.

Model answer

First, a grey-cloud switch with a written runbook, plus an origin firewall change that lets direct traffic in only while the switch is on. Second, short TTLs on records that may need to move, so a change lands in minutes. Third, a status page and an operator path, such as tailnet access from Chapter 16, hosted outside Cloudflare, so you can tell users what happened and still reach the server.

Staff 8. Weigh the Tunnel against an allowlist. One VPS runs an admin panel and a public API. Recommend an approach and name the failure you accept by choosing it.

Model answer

Use a Tunnel for both: Access in front of the admin panel, and the API on its own hostname, with WAF rules and caching on the public side. The accepted failure is dependency. If Cloudflare or the tunnel daemon fails, both hostnames go dark, so the break-glass path must exist. An allowlist avoids that dependency but leaves the origin reachable by anyone who learns its address. Either way, plan for upload limits and long responses on the API.

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