How can an application see the real client IP behind Docker's NAT?
AdvancedConceptNetworking
Answer
With the userland proxy, connections from localhost or hairpin can appear as the bridge gateway IP. Remote clients keep their source IP with plain iptables DNAT. In Swarm ingress the IP is SNATed unless you use host-mode publishing. Behind a proxy, rely on X-Forwarded-For or PROXY protocol, and trust only your proxy.
More on Networking
What network drivers does Docker have?BeginnerHow does the default bridge network work?AdvancedDefault bridge vs user-defined bridge: what is the difference?IntermediateHow does container DNS work?IntermediateHow does `-p 8080:80` work under the hood?AdvancedWhat is the difference between `-p 80:80` and `-p 127.0.0.1:80:80`?Beginner