I’m working on a Sinatra app and using request.ip returned the wrong IP address on OpenShift. This is due to OpenShift running a reverse proxy. After doing some searching online, I found the best way to get the user’s real IP address is as follows:
Ignoring the syntax (which isn’t very Ruby-like) and the use of a global variable (oh no!), this worked for me on OpenShift. Now, instead of getting a reverse proxy IP, I get the user’s real IP address.