B
B
bumbay2014-09-05 06:58:49
Node.js
bumbay, 2014-09-05 06:58:49

How to display client ip on localhost node server?

var getClientAddress = function (req) {
    return (req.headers['x-forwarded-for'] || '').split(',')[0] 
        || req.connection.remoteAddress;
};

Displayed ip 127.0.0.1.
How to be?
app.enabled('trust proxy')
Did not help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Shemsedinov, 2014-09-05
@bumbay

Try the "X-Forwarded-For" header case, but most likely the proxy simply does not set it, you need to configure nginx or haproxy or whatever is used there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question