Chapters

Capstone 1: a photo, through a VM to the database

This chapter follows one real request through everything the course built: from a shopper's phone, through Cloudflare and Google's load balancer, to a VM in a managed instance group that asks Cloud SQL and Cloud Storage for what it needs, and all the way back. At each hop you see what happens, which setting decides it, what the packet looks like, and which log records it. Then you break things on purpose.

Running it · chapter 25 of 26 · 2 min read

How to use this chapter

#ModeWhat it shows
1Request pathEight hops from the shopper to the database and back to the VM. Step with "Next hop"
2Return pathThe answer travelling back, where stateful firewalls, caches and logs do their part
3Break itSeven real misconfigurations from earlier chapters: where the request fails, what the shopper sees, and the log line that gives it away
Watch the Packet box as you step: the source and destination change at every proxy. Shopper, Cloudflare, Google's front end and the VM each see a different "client".

The walk

kade-vpc · sn-appShopper203.0.113.99Cloudflare DNSkade.lk zoneCloudflare edgeColomboGoogle LBfront end · ArmorBackend servicekade-media-backendkade-media VM10.10.1.31 · MIGCloud DNSprivate zoneCloud SQL10.10.32.3Cloud Storageoriginal photos
hop 1 of 8

hop 1 of 8 · Find www.kade.lk

What happens

The phone asks DNS for www.kade.lk. Cloudflare is authoritative, and the record is orange, so the answer is a Cloudflare address, not Kadé's load balancer.

Decided by

Cloudflare holds the zone; proxied (orange) record (chapter 13)

Packet

UDP 53 (or DNS over HTTPS) Q: www.kade.lk A? A: 104.21.48.12 (Cloudflare)

Recorded in

Cloudflare DNS analytics

Who sees which address

The same request has four different "clients", depending on who is looking. Most "wrong IP in the logs" confusion comes from mixing these up:

#Who is lookingSees the client asReal shopper's IP is inChapter
1Cloudflare203.0.113.99, the shopperThe connection itself13
2Google's front end, Cloud Armor104.23.211.40, a Cloudflare edgeCF-Connecting-IP13
3kade-media's VM (TCP)35.191.8.20, Google's front endCF-Connecting-IP, or X-Forwarded-For counted from the right12.1
4Cloud SQL, Cloud Storage10.10.1.31, the VMNowhere: they serve the VM, not the shopper9

Every layer that protected this request

Nine separate controls touched this one photo request. Each one covers a gap the others leave:

#ControlStopsChapter
1Cloudflare WAF and DDoSAttacks and floods, before they reach Google13
2Full (strict) TLS on both legsAnyone reading or changing traffic between Cloudflare and Google13
3Cloud Armor origin lockAnyone going around Cloudflare to the load balancer13
4Cloud Armor WAF rulesAttacks that got past Cloudflare12.1
5No external IP on any VMAnyone reaching kade-media without the load balancer3, 12.2
6Firewall by service accountAnything but Google's front ends reaching port 80805.1
7Cloud SQL: private IP, encrypted onlyThe database being reachable or readable from outside9
8Private Google Access, IAM on the bucketThe VM needing the internet, or any key file, to read photos9
9Org policies and folder firewall policySomeone undoing items 5 to 7 with a console click17

Self-check

Six questions about this path. Each answer links back to the chapter that explains it:

  1. 1.Google's front end sees the client as 104.23.211.40. What is that address?

  2. 2.Every photo request fails with 502 and the LB log says failed_to_pick_backend. What do you check first?

  3. 3.Why does kade-media need no firewall rule to receive Cloud SQL's replies?

  4. 4.kade-media has no external IP. How does it read from Cloud Storage?

  5. 5.A visitor gets ERR_TOO_MANY_REDIRECTS. Which setting do you check?

  6. 6.Which log shows that the load balancer, not the app, produced an error?

0 of 0 right · 6 left

Spotted a mistake, or something unclear? Suggest an edit on GitHub