Permalink
Browse files

Report correct clientIp when using reverse/forward-proxies

  • Loading branch information...
1 parent e6d4094 commit 38da2b096b43adbb2a814d94bd0ff6eda060d5c3 @sveisvei sveisvei committed Sep 23, 2012
Showing with 3 additions and 0 deletions.
  1. +3 −0 src/websocket/transports/socketio/index.coffee
@@ -35,6 +35,9 @@ module.exports = (ss, emitter, httpServer, config = {}) ->
try
[responderId, content] = utils.parseWsMessage(msg)
clientIp = socket.manager.handshaken[socket.id].address.address
+ if socket.manager.handshaken[socket.id].headers['x-forwarded-for']
+ clientIp = socket.manager.handshaken[socket.id].headers['x-forwarded-for'].split(',')[0]
+
meta = {socketId: socket.id, sessionId: socket.sessionId, clientIp: clientIp, transport: 'socketio'}
emitter.emit responderId, content, meta, (data) ->
socket.send(responderId + '|' + data)

0 comments on commit 38da2b0

Please sign in to comment.