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.

All Docker questions Roadmap: Docker & containers

More on Networking