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 suspecti开发者_如何学JAVAng Rack or WEBrick can... (or Mongrel or Thin)
精彩评论