Prologue — Two Journeys
“Every request is a short trip through a town you have never walked.”
The story: two trips, one town
Section titled “The story: two trips, one town”If you’ve read Book 1, The Glue, you’ve already seen the internet from the browser’s side of the counter. You know how a page is asked for, how cookies ride along, and how a cache decides what to remember. You have also deployed a Next.js app to an Oracle Cloud VPS, touched nginx, SSH’d into a box, and pointed a domain at Cloudflare and watched the cloud turn orange. Your deploys work. That is the good news, and it is also the trap. Things work, and you can’t always say why they work, which means you can’t say what to check at 2 a.m. when they stop.
This book is about the why. Not every protocol from the bottom up, because Book 1 covered a lot of that ground and I’ll link back rather than re-teach it. This book is about the part of the machine between your laptop and your code: names, addresses, routes, doors, guards, and the receptionists who walk a request to the right office.
We’ll describe all of it as a town. The metaphor is light, and I’ll keep it consistent. An IP address is a street address. A port is a numbered door on a building. A firewall is a guard with a clipboard who decides who gets past the gate. DNS is the city directory. A reverse proxy is the receptionist, who looks at who walked in and sends them to the right office at the back. Your app is that office.
The town has a few stranger features too. Your home router is a gated society, and the guard at the gate writes down everyone who goes out, so that replies can find their way back in. Cloudflare is a doorman stationed far away, screening visitors before they ever reach your street. Tailscale is a private corridor between your own buildings. And the people rattling every doorknob on the lane are scanners. They are weather, not personal, and we’ll treat them that way.
Your town is small and specific. Your lab is a throwaway VPS, never production. Its hostname is lab, its public address is 203.0.113.10, and its private address is 10.0.0.5. Your admin user is ops, and the app user is app. On it runs a tiny Node program called hello-pipes that prints back the host it was asked for, the client’s IP, and the headers it arrived with. The lab domain is pipeslab.in, with app., api., staging., admin. and status. in front of it. Your laptop sits behind a home router at 192.168.1.7, on a home line whose public address is 198.51.100.23. Those are documentation addresses, so nothing here points at a real machine, and you can practise on them freely.
Your projects are where these trips start and end. The Bollywood box-office site, the research SaaS on its Oracle box, the dance-academy app with its Razorpay webhooks and Resend email, and the team-status tool for your eight colleagues all live in this town. Each one has at least one door you have opened without quite knowing what it was.
The map
Section titled “The map”Before we walk anywhere, look at the whole town once. Figure P.1 is the territory map. You don’t need to memorise it. Notice that every stop on both journeys has a place on it, and that the numbers and letters come back in the text.
Read it left to right. Your side is on the left, the internet is the cloud in the middle, and the lab VPS is the building on the right. Amber marks the untrusted world, blue marks the guards, purple marks anything encrypted, and teal marks the places where a request is handled.
Journey one: a visitor reaches your app
Section titled “Journey one: a visitor reaches your app”Start with someone you will never meet. She is on a train out of Pune, phone in hand, and she types app.pipeslab.in into the address bar. Nothing about that is unusual. It happens millions of times a day, and the whole trip takes less time than it takes to read this sentence. Our job is to slow it down and look at each door.
The numbers below match Figure P.1. Each step ends with the chapter where the machinery gets its proper treatment. Read the text for the shape, and the chapter for the why.
Step 1. The name finds the directory
Section titled “Step 1. The name finds the directory”The phone has a name, not a place. Packets are routed by numbers, so the first job is to turn app.pipeslab.in into a street address. The phone asks a resolver, and the resolver walks a chain of referrals, from the top of the naming tree down to the nameservers that own pipeslab.in. The answer comes back with an address and a time to live, which tells everyone how long to remember it. That one number explains a lot of “I changed the record but the old one still shows up.” → Chapter 10, with the domain side in Chapter 11.
Step 2. The name may point at a doorman
Section titled “Step 2. The name may point at a doorman”If the record is proxied through Cloudflare, the directory hands back a Cloudflare address, not your VPS. The request meets a doorman stationed far away, at an edge location. The doorman screens the visitor, may answer from cache, and then forwards the request along a path you configured. If the record is DNS-only, the directory gives back 203.0.113.10 directly, and there is no doorman at all. Both paths end at the same building. Which one you are on is a choice, and it changes what the building can see. → Chapter 17.
Step 3. The subdomain picks the office
Section titled “Step 3. The subdomain picks the office”app., api., staging. and admin. can all point at one address. The street is the same. The name is what sets them apart, and the receptionist uses that name later to choose an office. Subdomains are just more DNS records, so the story carries over. → Chapter 12. Mail runs on records of its own, which is why a site can work perfectly while the emails it sends never arrive. → Chapter 13.
Step 4. The packet needs a route
Section titled “Step 4. The packet needs a route”The address is known, so the packet can leave. Routers pass it from network to network, each one choosing the next hop from a table, until it reaches the network where 203.0.113.10 lives. Routes are the roads between towns. You rarely think about them until one is closed. → Chapter 2.
Step 5. Two guards, two clipboards
Section titled “Step 5. Two guards, two clipboards”Before the packet reaches the VPS, it passes the cloud provider’s firewall. This guard stands at the outer gate of the building. It is configured in the provider’s console, and it sees the packet before the machine does. If it refuses, the packet is dropped and your server never hears about it. The packet then meets the host firewall, a second guard inside the building, running on the VPS itself. Either guard can say no, and a mistake in one is often hidden by the other, which is why you need to know both exist. → Chapter 14.
Step 6. The door is numbered 443
Section titled “Step 6. The door is numbered 443”The guard checks the door number on the packet. Port 443 is the door for HTTPS, the encrypted web. Port 80 is the plain-text door that usually exists only to send people on to 443. Doors are not secrets. Anyone can knock on any of them. The only question is whether something is listening behind the door. → Chapter 3.
Step 7. The receptionist reads the name
Section titled “Step 7. The receptionist reads the name”Something is listening, and on this VPS it is nginx or Caddy, the receptionist at the front desk. The receptionist reads the Host header, which says the visitor asked for app.pipeslab.in, and picks the office. This is the moment the name you typed matters. The same door can serve api.pipeslab.in and status.pipeslab.in, each sent to a different office. → Chapter 8.
Step 8. The receptionist checks the certificate
Section titled “Step 8. The receptionist checks the certificate”The visitor’s browser opened an encrypted channel with TLS. The receptionist holds the certificate and its private key, completes the handshake, and decrypts the request. This is called TLS termination. It is a deliberate choice: the encryption ends at the front desk, and the office at the back does not have to carry it. → Chapter 9.
Step 9. The office is at the back, on loopback
Section titled “Step 9. The office is at the back, on loopback”The receptionist forwards the request to 127.0.0.1:3000. That address means “this machine, and only from inside.” The Next.js app listens there, and nothing on the street can reach it directly. Port 3000 is not open in the host firewall, and it doesn’t need to be. Loopback is the back room: visible from inside the building, invisible from the lane. → Chapter 3 and Chapter 7.
Step 10. The records room, and the way back
Section titled “Step 10. The records room, and the way back”The app asks Postgres for data. The cylinder on the map is a store, and it should listen on loopback or a private interface, never the street. The app builds its answer, the receptionist adds its headers, and the reply retraces the path it came by. The firewalls don’t need to be told. They remember the conversation. → Chapter 7.
Journey two: you reach your server
Section titled “Journey two: you reach your server”Now the second trip, the one you take each time you type ssh lab. This time you are the visitor, and the building at the far end is yours to run.
Step A: leave the laptop through the gate
Section titled “Step A: leave the laptop through the gate”Your laptop sits behind your home router. It has a private address, 192.168.1.7, which means nothing outside your house. The router owns the one public address your ISP gave you, 198.51.100.23, and it acts as the gate of your gated society. When a packet leaves the laptop, the gate guard writes the sender in a logbook and swaps in the public address. When the reply comes back, the guard checks the logbook and lets it in. That trick is NAT, and it is why your laptop can reach the world while the world cannot walk straight in.
Some ISPs add a second gate. They share one public address across many homes. That is CGNAT: a gated society inside a gated township. Then the public address you were promised does not exist at all, and port forwarding cannot help. Keep that in mind, because it explains why step C has a second route.
Step B: packets find a road
Section titled “Step B: packets find a road”The packets leave your home network and join the wider internet. They do not travel as one car on one road. Each one is a small parcel, handed from router to router like boxes passed down a sorting line. At every junction a router looks at the destination address and picks the next hop from its own table. No single router knows the whole route. Most of them only know the next junction.
That is why the same server can feel quick from Pune and sluggish from across an ocean, and why a path can shift in the middle of a conversation.
Step C: knock on the VPS
Section titled “Step C: knock on the VPS”You have two ways in. The first is the public door: port 22, the SSH door, open at 203.0.113.10. The second is a private tunnel. With Tailscale on both your laptop and the VPS, your laptop reaches the server at a tailnet address such as 100.101.102.103, inside an encrypted tunnel that strangers on the street cannot see or knock on.
For the lab, and for any server you care about, I recommend the tunnel. The public door works fine. It is also the one that gets the most knocks.
→ Chapter 16 and Appendix F
Step D: the door asks who you are
Section titled “Step D: the door asks who you are”Port 22 belongs to sshd, the SSH daemon. It answers and shows its host key first. The host key is the server’s identity card. The first time, your laptop asks you to accept it and records it in known_hosts. On every later visit it checks that the card still matches. If the card changes, ssh warns you loudly. That warning means the building may not be the one you remember: a rebuilt server, or a stranger wearing the old badge. Do not click past it on autopilot.
Then you prove who you are. With key authentication, your private key never leaves the laptop. The server holds only the matching public key, in authorized_keys, and sends a challenge that only your private key can answer. A password proves the same thing in a weaker way, which is why we turn passwords off.
Step E: a shell as ops
Section titled “Step E: a shell as ops”Once you are through, the door opens onto an office with a desk: a shell on an Ubuntu Linux box, running as the user ops. Everything you type runs as that user. Your app runs as a different user, app, which cannot do what ops can. Keeping those roles apart is one of the cheapest safety habits you will learn.
Steps D and E happen inside the building, past the edge of the map. The first three steps, A to C, carry the letters on Figure P.1. You have now walked both roads once, at fly-over height.
Seven questions, one map
Section titled “Seven questions, one map”Both journeys cross the same seven layers, and when something breaks, it almost always breaks at exactly one of them. That’s why this book keeps repeating one line, which you’ll meet properly in Chapter 3:
Name → Address → Route → Door → Guard → Receptionist → App
Notice how different the answers feel. “Connection timed out” lives on the left half of that row: something on the road or a guard swallowed your packet in silence. “502 Bad Gateway” lives on the far right: you got all the way to the receptionist, and the office behind her didn’t answer. By Chapter 20 you’ll read an error message the way a doctor reads a symptom, and walk straight to the right rung.
How to read this book
Section titled “How to read this book”The book has six parts, and they follow the map from the ground up:
- Part I: The network you’re standing on (Ch 1–3): addresses, packets, ports. The physics of the city.
- Part II: The server (Ch 4–7): what a VPS really is, Linux for owners, SSH, and running apps properly.
- Part III: The front door (Ch 8–9): the receptionist and the certificates she shows.
- Part IV: Names (Ch 10–13): DNS, who really owns a domain, subdomains, and email.
- Part V: Locking it down and reaching in (Ch 14–18): firewalls, the hostile internet, Tailscale, Cloudflare, and how to choose.
- Part VI: Staying alive (Ch 19–20): backups, monitoring, and the 2 a.m. drill.
Every chapter opens with a “you are here” inset of this map. Each one ends with a self-quiz and exercises in three tiers: warm-ups to check your reading, labs on a running project, and staff-level challenges where you write the proposal, explain it to a PM, or draw the system for a design review. Solutions hide in collapsible blocks. Peek only after you’ve committed to an answer.
The labs all happen on one throwaway lab VPS: a cheap or free cloud server you’re allowed to break, never your production box. You’ll start it carelessly in Chapter 4, with an app open to the whole internet on port 3000. By Chapter 17 it will have no public SSH port, an app served through a tunnel with zero inbound ports, and a staging site behind a login. Watching one server grow up is the point.
Seven chapters have interactive demos that load when you scroll to them: a CIDR visualiser, a TCP handshake with adjustable latency, an SSH host-key walkthrough, an nginx matching playground, DNS resolution with TTLs ticking down, a “which guard stopped me?” firewall simulator, and NAT traversal. Each demo also explains itself in plain text, in case scripts are off.
Callouts keep their meanings from Book 1: 💡 mental models, ⚠️ gotchas, 🔥 war stories, 🧑🏫 whiteboard versions, 🎯 staff-level insights and 😄 asides. This book adds one more:
Make a cup of chai. Open a terminal. Somewhere a brand-new server is getting its first doorknob rattled right now, and by the end of this book you’ll know exactly which guard turned the visitor away, and why.
Book 2 of a series. Book 1: The Glue.