Created
May 18, 2015 21:31
-
-
Save kleinron/5f66b08cc125c05e6eff to your computer and use it in GitHub Desktop.
When using Morgan as the access log writer, in a Vanilla server, use this snippet to respect the x-forwarded-for header as the original client's ip address.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
morgan.token('remote-addr', function (req, res) { | |
var ffHeaderValue = req.headers['x-forwarded-for']; | |
return ffHeaderValue || req.connection.remoteAddress; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for this tip