Http in - remote address

1,301 views
Skip to first unread message

Vlad Livshitz

unread,
Dec 11, 2014, 7:44:05 AM12/11/14
to node...@googlegroups.com
Hi,

How to get remote data from "http in" node?

I created a such node and redirected the request related data to console - i did not find any relevant IP there,

So, how can i collect statistic log?

Thanks

Lawrence Griffiths

unread,
Dec 11, 2014, 8:49:40 AM12/11/14
to node...@googlegroups.com
Vlad msg.req.ip

NodeRed uses Express so you can access Express Request Object to get at parameters  

Lawrence

Vlad Livshitz

unread,
Dec 11, 2014, 9:24:13 AM12/11/14
to node...@googlegroups.com
Lawrence,

thank you for this response.

Yes, i can see an IP  address in such way!

But, I still don't understand,  when i printed a whole msg to console, why I was not able find the IP?

And another issue, i'm running my app on IBM BlueMix. So all addresses that I get are address of SoftLayer. I.e. it seems that request is redirected... Here, i guess, I can't do anything...

Thanks!

Nicholas O'Leary

unread,
Dec 11, 2014, 9:44:06 AM12/11/14
to node...@googlegroups.com
Vlad,

how are you printing the whole message to the console? The debug node, by default, only displays the value of msg.payload. 

As for running the Bluemix, you are seeing the IP address of the proxy that sits in front of VMs running the actual applications.

By inspection, I think the proxy sets the http header "x-client-ip" to the IP address of the original requesting client:

    var ip = msg.req.get("x-client-ip")

Nick


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lawrence Griffiths

unread,
Dec 11, 2014, 12:54:36 PM12/11/14
to node...@googlegroups.com
Vlad you might also want to look at this req.ips

When "trust proxy" is true, parse the "X-Forwarded-For" ip address list and return an array. Otherwise, an empty array is returned.
For example, if the value were "client, proxy1, proxy2", you would receive the array ["client", "proxy1", "proxy2"], where "proxy2" is the furthest down-stream.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Vlad Livshitz

unread,
Dec 11, 2014, 4:42:00 PM12/11/14
to node...@googlegroups.com
Thank you,

The assignment var ip = msg.req.get("x-client-ip") solves my problem!
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Vlad Livshitz

unread,
Dec 11, 2014, 4:45:10 PM12/11/14
to node...@googlegroups.com
Thanks, i tried, but i obtained empty list.

Now i use

var ip = msg.req.get("x-client-ip")

from previous post to get an IP.

Thank you

P.S. I need IP to apply some security polices for my POC.
In the future i would like to protect the webpage with password. Do you have a tip how to do it?

Thank you
Reply all
Reply to author
Forward
0 new messages