Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if use proxy, can't show the real ip #2

Closed
wohugb opened this issue Sep 19, 2015 · 2 comments
Closed

if use proxy, can't show the real ip #2

wohugb opened this issue Sep 19, 2015 · 2 comments

Comments

@wohugb
Copy link

wohugb commented Sep 19, 2015

change getip function in morgan module index.js, and req.headers['x-real-ip'] will show the real ip!

@fundon
Copy link
Member

fundon commented Sep 23, 2015

@wohugb You can custom the remote-addr token, like the below:

morgan.token('remote-addr', getip)

function getip(req) {
 // do something
}

@fundon fundon closed this as completed Sep 24, 2015
@JaosnHsieh
Copy link

@wohugb You can custom the remote-addr token, like the below:

morgan.token('remote-addr', getip)

function getip(req) {
 // do something
}

works well with proxy-addr

import proxyaddr from 'proxy-addr';
morgan.token('remote-addr', function(req, res) {
  return proxyaddr.all(req);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants