I have been trying to use the GeoIP Rack App, by copying this gist in my Rack stack with a Sinatra Application. Heroku has a lot of redirection in there Server farm so I have added the following lines to my instance of GeoIP:Rack to make it Heroku safe.

env['HTTP_X_REAL_IP'] ||= env['REMOTE_ADDR']
res = @db.country(env['HTTP_X_REAL_IP'])