Proxies, tunnels and firewalls
Public requests commonly cross a policy boundary before they reach an application. Without a clear account of that boundary, logs can confuse the client, the proxy and the server, and a permitted port can look like permission for everything. We will route through proxies, select backends, wrap packets in tunnels, and identify the state targeted by common attacks.
#Section 42Reverse proxies and TLS termination
A reverse proxy mediates access to servers; a forward proxy acts for clients. Its upstream exchange is a separate endpoint relationship, not proof that the original user directly reached the backend.
An HTTP reverse proxy can inspect Host, path and headers, select an upstream, cache an eligible representation, compress a response and enforce a rate limit. If it terminates TLS, Finch authenticates the proxy’s public certificate and the proxy can read HTTP plaintext. The backend connection then has its own encryption and authentication policy. End-to-end confidentiality stops at the termination point unless the application adds a further protection layer.
The backend’s network peer is now the proxy, not necessarily 198.51.100.7. Forwarded client metadata needs a trusted chain of intermediaries; accepting arbitrary client-supplied forwarding headers permits spoofed audit records or policy decisions. Timeouts also need ownership. A proxy can return 504 when its upstream deadline expires even if the backend eventually commits the operation.
Connection pooling lets a proxy reuse backend streams, but a pool can serialize or queue work at its own limit. Retries across that boundary must respect method semantics and request identifiers. A proxy retrying an uncertain state-changing operation can duplicate effects despite reliable individual TCP connections.
Nginx documents HTTP proxying through an upstream directive and related response behavior. The architectural question is where TCP and TLS end and where another exchange begins. Draw those terminations explicitly in an interview; saying the proxy merely passes the original connection through would misdescribe HTTP termination.
#Section 43Load balancing, health checks and sticky sessions
Load balancing chooses among targets using policy and health evidence. Adding admissions backends does not automatically make their independent session state consistent.
L4 and L7
An L4 balancer selects using transport and network information, commonly choosing a target for a connection. An L7 balancer understands application messages and can route by HTTP host, path or other request properties. TLS termination is often necessary for an intermediary to inspect encrypted HTTP, which adds certificate and plaintext responsibilities.
Round robin rotates through targets; weighted round robin changes their allocation shares. In the illustrative equal-weight sequence, 9 requests over 3 targets give 3 requests each. Least connections chooses the target with fewer active connections, which can misrepresent load if one connection carries much more work. Hashing a key keeps related work together; consistent hashing limits remapping when membership changes.
A health check samples a target through a probe. It can detect a dead listener yet miss a failing dependency unless its probe tests that dependency deliberately. Failover removes or avoids a target after the configured evidence, but existing connections and requests still need recovery. A timeout is evidence of a missed deadline, not proof a target never executed the request.
Sticky sessions keep related clients on the same backend. They can reduce state transfer but create uneven load and complicate target failure. If login state exists only on that machine, moving Finch elsewhere may lose its session. Choose whether the application uses a shared store, replicated state or acceptable session loss before promising failover. A load balancer distributes capacity; it does not erase the state ownership question.
#Section 44Forward proxies, VPNs and tunnels
A tunnel wraps a packet in another carrier. A VPN combines a logical private path with its authentication, encryption, and policy contract.
A forward HTTP proxy handles a client’s web requests; an HTTPS CONNECT tunnel can carry encrypted bytes without inspecting their HTTP content. A SOCKS proxy relays application connections under its own negotiation. An SSH tunnel forwards selected ports over an authenticated SSH connection. A VPN instead commonly installs a virtual interface and routes selected network traffic through it, potentially covering several applications.
WireGuard and IPsec are different protocol families for protecting network traffic. WireGuard associates cryptographic peers with allowed addresses, while IPsec policies and security associations define protected packet handling. Naming a VPN product does not specify which routes are installed, where DNS goes or what happens if the tunnel drops. A split route sends selected destinations through the tunnel; a default route can direct most traffic there.
Encapsulation spends a byte budget. Finch’s unwrapped 1,500 byte packet cannot fit unchanged inside another 1,500 byte path allowance after an outer header is added. The sender needs a smaller inner MTU, supported fragmentation or packet-too-big feedback. Otherwise large transfers may stall while small probes succeed.
A tunnel moves the trust boundary rather than abolishing it. Its exit can observe unprotected application traffic, and the peer still needs authorization to reach destinations inside the private network. WireGuard’s protocol description distinguishes cryptographic transport from ordinary packet routing. An interview answer should name the inner endpoints, outer endpoints, route selection and payload budget.
#Section 45Stateless and stateful firewalls
A firewall enforces traffic-crossing rules. Ingress and egress mean entering and leaving a named boundary; neither establishes that the application operation is authorized.
A stateless filter evaluates each packet independently. A stateful firewall uses connection tracking to associate packets with an observed exchange. It can permit replies to admitted flows without allowing every unsolicited packet on a client’s temporary port. Tracking state is a resource with memory and expiry costs, especially for UDP mappings without transport establishment.
Finch’s outbound tuple changes from 192.168.10.70:51000 to 198.51.100.7:40001. NAT state restores the return destination, while firewall state decides whether the packet may cross. These can share implementation machinery without becoming the same policy. An address translation is not proof that every allowed application request is authorized.
Rule ordering and default policy matter. An earlier broad allow can make a later narrow deny ineffective. Blocking ICMP indiscriminately can also obstruct useful path-MTU feedback. A drop gives the sender no immediate rejection, whereas a reject may return a protocol-appropriate indication. Both choices affect diagnosis and should express the intended exposure.
A firewall seeing only encrypted TCP bytes cannot enforce an HTTP path policy without another inspection boundary. Conversely, an application authorization check cannot protect a kernel service exposed through an unrelated port. Explain defenses by the state each can observe and the decision each makes. That is more useful than treating a firewall as a general guarantee against malicious content.
#Section 46Sniffing, spoofing, floods and replay attacks
Spoofing presents a false identity; packet sniffing observes available traffic. A man-in-the-middle attack interposes between peers. A forged gateway ARP update attacks local delivery before HTTP begins.
ARP spoofing poisons a local mapping, while DNS poisoning supplies a false name answer. IP spoofing forges a source address but does not ordinarily give the attacker the return route needed for a normal TCP handshake. TLS hostname verification can detect an impostor service even if lower-layer redirection succeeds, although compromised keys or trust anchors change that conclusion.
A SYN flood consumes pending connection resources. SYN cookies can defer some server allocation by encoding state into the server’s sequence response, with capability tradeoffs. A distributed denial-of-service attack can exhaust bandwidth before packets reach the server firewall, requiring filtering or absorption upstream. Application rate limits help when the service can still admit and classify requests; they cannot recover an already saturated access link.
A replay attack reuses previously valid traffic or credentials. TLS record protection rejects ordinary record replay within its established context, but permitted early data and application retries need their own replay policy. Session hijacking uses a stolen bearer credential; Secure and HttpOnly reduce particular theft paths without making an injected script harmless.
Finch’s CRC remainder 001 detects selected accidental bit errors and offers no peer authentication. An attacker can recompute a CRC after modifying plaintext. Pair each defense with its threat model, such as encrypted authenticated transport for intercepted content, anti-spoofing policy for forged sources, secure resolver practices for name answers, and bounded admission for state exhaustion. There is no single layer that addresses them all.