RB
Languages & HTTP Clients

Ruby (Net::HTTP) proxy integration

Ruby's standard Net::HTTP supports proxies through Net::HTTP.new with proxy host, port, user, and password arguments. This routes your Ruby requests through Aethyn residential IPs without extra gems.

Setup steps

  1. 1Use Net::HTTP.new with proxy host, port, user, and password.
  2. 2Build the request and call request on the proxied connection.
  3. 3Embed targeting suffixes in the proxy username.
  4. 4Wrap in start for connection reuse.

Code

Net::HTTP with proxy
require 'net/http'
require 'uri'

uri = URI('https://httpbin.org/ip')
http = Net::HTTP.new(uri.host, uri.port,
  'proxy.aethyn.io', 2099,
  'aethyn-XXXXX-country-us', 'PASSWORD')
http.use_ssl = true

puts http.get(uri.request_uri).body

Replace aethyn-XXXXX and PASSWORD with your dashboard credentials. See the full targeting reference and protocol/port list.

Tips

  • Set use_ssl = true for HTTPS targets.
  • Reuse the http object inside a start block for multiple requests.
  • For higher-level needs, the Faraday or HTTParty gems accept the same proxy.

Ruby (Net::HTTP) proxy FAQ

Do I need a gem for proxies in Ruby?
No. The standard library Net::HTTP accepts proxy host, port, username, and password directly. Gems like Faraday are optional conveniences.

Ready to wire up Ruby (Net::HTTP)?

Get your credentials and route your first Ruby (Net::HTTP) request through residential IPs in minutes.

Docs, solutions & blog

Related integrations

All integrations