Reputation: 83
Is it possible to get the ip address of server's private ip? i.e., local ip of users who are all accessing my site.
i tried using
request.remote_ip
request.env['HTTP_X_REAL_IP']
request.env['REMOTE_ADDR']
request.env["HTTP_X_FORWARDED_FOR"]
Net::HTTP.get(URI.parse('http://checkip.amazonaws.com/'))
request.env['REMOTE_HOST']
request.remote_addr
request.env['HTTP_CLIENT_IP']
using socket
but it shows same ip for all the users.
Thanks in advance.
Upvotes: 0
Views: 2571
Reputation: 704
You should use request.remote_addr
.
The code you used request.remote_ip
is used in rails, not in Ruby.
Hope it helped.
Upvotes: 2