How to add a proxy server to Ruby Geocoder

Ruby Geocoder is the most complete solution for geocoding available in Ruby and can hook in to a number of different geocoding APIs.

One undocumented feature is its ability to route all requests through a proxy server. This can be very useful when trying to use Ruby Geocoder with Heroku or other PaaS that hide behind shared ip addresses as it allows you to reclaim your daily request usage from Google. This example shows it using the QuotaGuard proxy. Note that for unauthenticated connections you don’t need the username:password@ prefix.

Its also a good idea to up the timeout a bit as going through a proxy may slow your request down.

# config/initializers/geocoder.rb

  :http_proxy => 'username:password@',
  :timeout => 5