drogon
drogon copied to clipboard
Support retreving IP information from `X-Forwarded-For` header
As of now, when drogon is running behind a reverse proxy, drogon can only see the reverse proxy's IP as the peer IP. Which is technically true. But not what we want. Causing AccessLogger logging the IP of the proxy, etc... This PR adds an option trustProxy to listeners (name taken from express.js). When set, it uses the information in X-Forwarded-For header for the peer IP.
I have a little doubt if we should overwrite peerAddr_. I think user would expect that getPeerAddr() returns the same thing as ::getpeername() does? At least I'm expecting that.
Resolved by RealIpResolver #1321