Chances are you have a Web server fronting your requests (Apache/
Nginx), which has the actual IP the request came in on (LOL I just
wrote "the actual request the IP came in on" before I fixed it; get
*that* auto-correct).

The http headers (especially if passed on) will include the hostname,
will they also include the request IP? You could probably configure
your front-end server (Apache or Nginx) to add it as an http header in
the request to the node app server, and then pull it from
request.headers, if it really matters.

The more interesting question might be why you are doing this in the
first place? If this is a classic Web app, you shouldn't need it
inside your app, and might make it brittle. If it is some type of
other networking service, I can see how it might be needed. But why do
you need it, and is there a better solution?

On Feb 6, 9:04 pm, Ben Noordhuis <[email protected]> wrote:
> On Mon, Feb 6, 2012 at 19:15, AJ ONeal <[email protected]> wrote:
> > Can someone suggest a strategy for determining which IP address a request
> > came through?
>
> > I'm not looking for the IP address of the remote.
>
> > I want the IP address of the server.
>
> You mean the address the connection came in on a server with multiple 
> addresses?
>
> You can't. It's not a Node limitation, most (all?) operating systems
> don't provide that information. Bind to each address separately.

-- 
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

Reply via email to