0

Following the answer in this question: How to get client IP and Server IP using Rails

request.remote_ip shows 127.0.0.1

and

request.env["HTTP_X_FORWARDED_FOR"] shows nil

is there a way to show client's IP? (I am using Rails 3.0.5, with WEBrick as the server in development mode)

I am looking at this since our page has 2 Facebook Like buttons, and if it is a page I never loaded before, such as

http://www.foo.com:8088/products/123

then I see on my Rails server console that there are 3 accesses, and if I change the id to 456, it is 3 accesses again, but once I have looked at these pages and revisit them, now there is only one access, so looks like Facebook is caching the results on the first visits.

(note: I am using ssh reverse tunnel to forward www.foo.com:8088 to my localhost:3000 to access the Rails server, but if I directly access localhost:3000, it is the same result)

But I'd like to see the IP and do nslookup on it.

Update: if Rails can't do it, I am suspecting Rack or WEBrick can... (or Mongrel or Thin)

Community
  • 1
  • 1
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • 1
    It's worth saying that 127.0.0.1 is a real IP address — it's the loopback interface, otherwise known as localhost. In addition, I tried `nslookup` on 127.0.0.1, and it worked just as well as it did on any other IP address. – icktoofay Apr 01 '11 at 01:06
  • but the Facebook accessing the server, that one is also showing as `127.0.0.1` – nonopolarity Apr 01 '11 at 01:13

0 Answers0