让pomelo可以获取到反向代理websockets的真实用户IP

/home/pomelo/livegame/game-server/node_modules/pomelo/lib/connectors

找到

var Socket = function(id, socket) {

//ws模式,过滤IPV4前面的无用IPV6头
var ip = socket._socket.remoteAddress.replace(/::ffff:/, '');
var realIp = socket.upgradeReq.headers['x-forwarded-for'] || socket.upgradeReq.headers['x-real-ip'] || ip
this.remoteAddress = {
ip: ip,
port: socket._socket.remotePort,
realIp: realIp
};

上一篇:WeMos物联网开板实例入门-实现简单WebSocket服务器


下一篇:什么是 WebSockets?