I'm developing rails(2.3.8) application. I need to store actual client's remote IP address.
request.remote_ip
returns only 127.0.0.1
but I need to store actual remote IP such as 93.43.56.77
. Any ruby gems is available? or how do get that?
I'm developing rails(2.3.8) application. I need to store actual client's remote IP address.
request.remote_ip
returns only 127.0.0.1
but I need to store actual remote IP such as 93.43.56.77
. Any ruby gems is available? or how do get that?
Try this:
request.env['REMOTE_ADDR']
If your request is coming from your development machine and the development machine is where your server is, probably you will get 127.0.0.1
. But if the request is coming from another machine, this will be the IP the remote machine. However, under various conditions this may not be the real IP of the machine (machine behind proxy, using tor or other tool to hide it e.t.c.).
Your computer essentially has two network interfaces.
You will not get the application to show '93.43.56.77' unless the connection is running over that connection, which means it will need to be on a different computer.
If you are so concerned about it, you can easily push it up to Heroku where it should work as you expect.