Ruby Proxy Configuration Examples

This article describes options for configuring the Proxy Host with Basic Authentication in the Ruby scripting language for an HTTP client.

For Ruby HTTP clients, if you are using IP authentication, you can leave out the username:password parts.

Here's an example from the Typhoeus library:
options = {proxy: 'http://PROXYHOST:PORT', proxyuserpwd: 'USERNAME:PASSWORD'}
req =, options)

Below is a code example for a REST API call behind a proxy:

require "uri"
require 'net/http'

proxy_host = '<proxy addr>'
proxy_port = '<proxy_port>'
proxy_user = '<username>'
proxy_pass = '<password>'

uri = URI.parse("<username>")
proxy = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass)

req =

result = proxy.start(,uri.port) do |http|

puts result.body

Still need help? Contact Us Contact Us