Express.js Get Client IP
Express中如果想获取客户端的IP,首先要设置trust proxy: app.set('trust proxy', 1); // or app.enable('trust proxy'); 设置完之后,就可以从req中取到IP了: var ip = req.ip; // or ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; ...
Express中如果想获取客户端的IP,首先要设置trust proxy: app.set('trust proxy', 1); // or app.enable('trust proxy'); 设置完之后,就可以从req中取到IP了: var ip = req.ip; // or ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; ...