Interview Prep/Networking/Load Balancing, Proxies & CDN

Your app sees the load balancer's IP instead of the real client IP. How do you get the real one?

BeginnerScenarioLoad Balancing, Proxies & CDN
Answer

Situation read → Proxies replace the source address, so the original goes in a header or the PROXY protocol.

What I'd do →

  1. Read X-Forwarded-For (the left-most is the original client, but only trust entries added by your own proxies)
  2. In Nginx use set_real_ip_from 10.0.0.0/16; real_ip_header X-Forwarded-For;
  3. On NLB enable client IP preservation or PROXY protocol v2
  4. Log $http_x_forwarded_for and verify with curl -H 'X-Forwarded-For: 1.2.3.4' to confirm spoofing is handled

Why → A client can send any XFF value, so trust only the hops you control.

Interview tip → Say that rate limiting and allow lists on a spoofable header are a security bug.

All Networking questions Roadmap: Networking for DevOps

More on Load Balancing, Proxies & CDN