Getting the remote ip with Express

1,154 views
Skip to first unread message

Lemol-C

unread,
Dec 30, 2011, 9:35:44 PM12/30/11
to nod...@googlegroups.com

How do I?

--
Atenciosamente,

Leza Morais Lutonda, Lemol-C
http://www.lemolsoft.webs.com or @lemolsoft on twitter

mscdex

unread,
Dec 30, 2011, 9:40:15 PM12/30/11
to nodejs
On Dec 30, 9:35 pm, "Lemol-C" <leza...@fecrd.cujae.edu.cu> wrote:
> How do I?

Express gives you access to the HTTP request variable, so you can get
at the address with the property `req.socket.remoteAddress`.

Lemol-C

unread,
Dec 30, 2011, 10:02:26 PM12/30/11
to nod...@googlegroups.com

But why req.socket.remoteAddress is undefined?

ps: I'm using node v0.6.5 on windows.

Atenciosamente,

Leza Morais Lutonda, Lemol-C
http://www.lemolsoft.webs.com or @lemolsoft on twitter

-----Mensaje original-----
From: mscdex
Sent: Friday, December 30, 2011 10:40 PM
To: nodejs
Subject: [nodejs] Re: Getting the remote ip with Express

--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en


Alex Gadea

unread,
Dec 30, 2011, 10:28:23 PM12/30/11
to nod...@googlegroups.com
Are you running it under IISNode?  If yes, then the value will not be defined as IISNode acts as a proxy.  There is a request to resolve this issue via the X-Forwarded header.

Alex

Lemol-C

unread,
Dec 30, 2011, 10:58:07 PM12/30/11
to nod...@googlegroups.com
 
OK, but in my case req.headers['x-forwarded-for'] isn’t defined too!
 
Atenciosamente,

Leza Morais Lutonda, Lemol-C
http://www.lemolsoft.webs.com or @lemolsoft on twitter

Riadh KHÉDHIRI

unread,
Dec 31, 2011, 5:13:39 AM12/31/11
to nod...@googlegroups.com, Lemol-C
I think it's

req.connection.remoteAddress


but if you use you're app as a back-end, maybe you need this:

req.headers['x-forwarded-for']

Alex Gadea

unread,
Dec 31, 2011, 8:25:10 AM12/31/11
to nod...@googlegroups.com
I don't know that its been added yet - its a current issue I raised about two weeks ago.  Not sure if its made it into the latest builds yet.

Alex


From: lez...@fecrd.cujae.edu.cu
To: nod...@googlegroups.com
Subject: Re: [nodejs] Getting the remote ip with Express
Date: Fri, 30 Dec 2011 23:58:07 -0400

Tomasz Janczuk

unread,
Jan 26, 2012, 12:26:54 PM1/26/12
to nodejs
Support for x-forwarded-for has been added to iisnode with
https://github.com/tjanczuk/iisnode/issues/94.

Also check out related feature https://github.com/tjanczuk/iisnode/issues/87
for accessing IIS server side variables.

Thanks,
@tjanczuk
Reply all
Reply to author
Forward
0 new messages