log the IP address as seen by Express, if available #684

Merged
merged 1 commit into from Nov 3, 2012

3 participants

@natesilva

Currently, the connect.logger middleware logs the socket’s IP address.

Instead, it should prefer to log req.ip—the IP address as seen by Express. This is especially useful when the Express’ “trust proxy” option is enabled. In that case, it will log the user’s IP address, and not the proxy’s IP address.

If not using a proxy, or if req.ip is not available (for example, you’re not using Express), it will log the immediate IP address, as before.

Nate Silva log the IP address as seen by Express, if available
For `remote-addr`, the logging middleware should use `req.ip`, the IP
address seen by Express. This is especially useful when behind a proxy
with the Express “trust proxy” option. If `req.ip` is not enabled,
fallback to the traditional method.
b81f3b7
@rauchg

+1

@tj
Sencha Labs member
tj commented Nov 3, 2012

ideally we'd move express's stuff into an npm lib and add .logger({ trustProxy: true }) or something to make it less express specific but since this will just noop I'll merge for now

@tj tj merged commit 86a40ba into senchalabs:master Nov 3, 2012

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment