Skip to content

Instantly share code, notes, and snippets.

@johnrees
Created January 24, 2012 14:32
Show Gist options
  • Save johnrees/1670449 to your computer and use it in GitHub Desktop.
Save johnrees/1670449 to your computer and use it in GitHub Desktop.
Remote IP on Heroku
def remote_ip
if forwarded = request.env["HTTP_X_FORWARDED_FOR"]
forwarded.split(",").first
elsif addr = request.env["REMOTE_ADDR"]
addr
end
end
@zackster
Copy link

@jrochkind my post was 5 years ago.. yours is probably the correct answer for 2022. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment