Ruby standard library Net::HTTP with proxy support. Route HTTP requests through KnoxProxy using built-in Ruby networking.
Use Net::HTTP proxy class method.
require 'net/http'
require 'uri'
proxy = Net::HTTP::Proxy("gw.knoxproxy.com", 7000, "USER", "PASS")Use the proxy class.
uri = URI("https://httpbin.org/ip")
response = proxy.get_response(uri)
puts response.bodyModify username.
proxy = Net::HTTP::Proxy("gw.knoxproxy.com", 7000, "USER-country-de", "PASS")Verify exit IP.
Set read and open timeout.
http = proxy.new(uri.host, uri.port)
http.open_timeout = 30
http.read_timeout = 30Enable SSL.
http.use_ssl = true# KnoxProxy + Ruby Net::HTTP
require 'net/http'
require 'uri'
require 'json'
proxy_class = Net::HTTP::Proxy("gw.knoxproxy.com", 7000, "USER", "PASS")
uri = URI("https://httpbin.org/ip")
http = proxy_class.new(uri.host, uri.port)
http.use_ssl = true
http.open_timeout = 30
http.read_timeout = 30
response = http.get(uri.path)
data = JSON.parse(response.body)
puts "Exit IP: #{data['origin']}"Each new Net::HTTP connection gets a fresh IP. Reuse connections for sticky behavior.
| Problem | Fix |
|---|---|
| Errno::ECONNREFUSED | Verify host and port. |
| Net::HTTPUnauthorized (407) | Check username and password. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Yes. HTTParty: HTTParty.get(url, http_proxyaddr: host, http_proxyport: port, http_proxyuser: user, http_proxypass: pass). Faraday: configure proxy in connection middleware.
Nokogiri is an HTML parser. Use Net::HTTP with KnoxProxy to fetch pages, then parse with Nokogiri.
Configure proxy in your HTTP client wrapper. For background jobs (Sidekiq), pass proxy settings to your HTTP calls.
Both work well. Python has more scraping libraries (Scrapy, BeautifulSoup). Ruby has cleaner syntax for quick scripts.
Free trial on rotating residential -- 3 minutes setup, no credit card.