Hacker News new | ask | show | jobs
by eoyola 6236 days ago
how do you get my ip? gets my lan ip 192.168.99.4 instead of the internet address.
1 comments

Does your LAN use a proxy? I am doing this:

@remote_ip = request.env["HTTP_X_FORWARDED_FOR"]

I'm guessing that your 192.168.99.4 is being sent. The reason I grab this is because lighttpd is acting as a load balancer and I need the IP to find your location. Bummer about that.

This is a problem I've encountered while building my own web app. There most be a way from PHP (or whatever else you're using) to know the real external IP of a user that comes to a site, isn't there? If anyone knows how to do this please let me know.
Apparently X-Forwarded-For is an array that has all the proxies in it. Check out this page and we should be able to fix the problem. Thanks molo for the tip.

http://en.wikipedia.org/wiki/X-Forwarded-For