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, both work. HTTParty.get(url, http_proxyaddr: "gw.knoxproxy.com", http_proxyport: 7000, http_proxyuser: "USER", http_proxypass: "PASS") sets the proxy per call. Faraday takes a similar proxy option in its connection block instead. Either library sits on top of the same underlying Net::HTTP proxy mechanism shown in the standard-library example above.
Nokogiri itself is only an HTML and XML parser, so it has no proxy setting of its own. Fetch the page first with the proxied Net::HTTP::Proxy connection shown above, then pass the resulting response body into Nokogiri::HTML(response.body) for parsing. The proxy and the parser stay completely separate steps in the pipeline.
Configure the KnoxProxy proxy inside whatever HTTP client wrapper your Rails app already uses, whether that is Net::HTTP::Proxy, HTTParty, or Faraday, as in a standalone Ruby script. For background jobs using Sidekiq, pass the same proxy settings into each HTTP call made inside the job class, since Sidekiq workers do not inherit request-level configuration.
Both work well with KnoxProxy through built-in HTTP clients. Python has a larger scraping ecosystem, including Scrapy and BeautifulSoup, which matters for large or complex crawls. Ruby needs no extra gems for basic proxied requests with Net::HTTP and reads cleanly for quick one-off scripts, so the better choice depends on project scale.
Rotating residential proxies -- 3 minutes setup, instant activation, 14-day money-back guarantee.