This is useful if you want to log the ip address of the person using your rails app (except when the person is behind a proxy, thanks James!):
request.env['REMOTE_ADDR']
Taken from this ruby thread.
This is useful if you want to log the ip address of the person using your rails app (except when the person is behind a proxy, thanks James!):
request.env['REMOTE_ADDR']
Taken from this ruby thread.
3 Comments
Is this true when using a proxy?
You’re right, this won’t work so well when then client is behind a proxy.
However: I’m fairly sure (but too lazy to look it up) that there are ways (or there is *a* way) to have Mongrel pass this info along, possibly in an x-header field.
Anyway, the main point is that people using a Web app behind a proxy need to be sure the proxy is telling the truth when inspecting headers and ENV values.