标签:list get lin line tip etc bar nbsp bsp
在node层获取访问用户的ip地址
var express = require(‘express‘);
var app = express()
app.get(‘/‘, function(req, res){
console.log( getClientIp(req))
})
function getClientIp(req) {
return req.headers[‘x-forwarded-for‘] ||
req.connection.remoteAddress ||
req.socket.remoteAddress ||
req.connection.socket.remoteAddress;
};
app.listen(3000)
标签:list get lin line tip etc bar nbsp bsp
原文地址:http://www.cnblogs.com/zhangshuda/p/7640357.html