title: How get client real IP when using nginx server in front of node as proxy
body: <p>I'n need to get client real IP address in nodeJs, when using nginx proxy server I always get my localhost(127.0.0.1). Can anyone help me to solv this problem? 
  Here is my code</p>
  
  <pre><code>app.set('trust proxy', 'loopback');
  app.use(function(req, res, next) {
    app.ipInfo = req.headers['x-forwarded-for'] ||
      req.connection.remoteAddress ||
      req.socket.remoteAddress ||
      req.connection.socket.remoteAddress;
    next();
  });
  </code></pre>