On Sat, Mar 3, 2012 at 00:39, Jimb Esser <[email protected]> wrote:
> We have a load balancer running in front of our node.js servers, so by
> the time the connection gets to our node.js server, the socket's
> remote address is always the IP of our load balancer. We want to get
> the original IP of the original connection, and most load balancers
> and SSL terminators (nginx, stud, HAProxy (we're using variants of the
> first two)) support inserting the original IP into the stream before
> the actual data (the HTTP request in the case of HTTP streams).
> Sadly, none of these support HTTP header rewriting at the same time
> as the other features we need (HTTP 1.1, WebSockets, single port,
> consistent/stateful load balancing), so it seems we must use the
> simple TCP-level load balancing option that just inserts the IP before
> the rest of the stream, which is simple to parse out, just not from
> userland.
The HTTP module doesn't support that directly but you can probably
hack around it with something like this:
var s = http.createServer(...);
var listeners = s.listeners('connection');
s.removeAllListeners('connection');
s.on('connection', function(conn) {
// read the IP address
...
// now fire the original listeners
listeners.forEach(function(listener) {
listener.call(s, conn);
});
});
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en