Ruby

NOTE: The documentation below assumes either FIXIE_URL or FIXIE_SOCKS_HOST Environment Variables are set. If your application is deployed on either Heroku or Vercel via our official integration, these environments will be set for you.

You can use Fixie with any Ruby http client. Included are examples of using it with Net::HTTP from the standard library and with popular rest-client or faraday gems.

Using rest-client

require 'rest-client'
RestClient.proxy = ENV["FIXIE_URL"]
response = RestClient.get("http://welcome.usefixie.com")

Using faraday

require 'faraday'
conn = Faraday.new(:url => "http://welcome.usefixie.com", :proxy => ENV["FIXIE_URL"])
response = conn.get

Using httparty

fixie = URI.parse ENV['FIXIE_URL']

HTTParty.get(
  "http://welcome.usefixie.com",
  http_proxyaddr: fixie.host,
  http_proxyport: fixie.port,
  http_proxyuser: fixie.user,
  http_proxypass: fixie.password
)

Using Net::HTTP from the standard library

require 'net/http'
_, username, password, host, port = ENV["FIXIE_URL"].gsub(/(:|\/|@)/,' ').squeeze(' ').split
uri       = URI("http://welcome.usefixie.com")
request   = Net::HTTP.new(uri.host, uri.port, host, port, username, password)
response  = request.get(uri)

Using net-sftp

Out of the box, any Ruby library that accepts Net::SSH::Proxy::SOCKS5 object can also use Fixie Socks. Here is a simple example of configuring the object that holds the proxy details:

proxy_uri = URI.parse("socks://#{FIXIE_SOCKS_HOST}")
socks_proxy = Net::SSH::Proxy::SOCKS5.new(
  proxy_uri.host,
  proxy_uri.port,
  user: proxy_uri.user,
  password: proxy_uri.password,
)

Leveraging the example above, here is an example of making an SFTP request through Fixie Socks using net-sftp gem:

Net::SFTP.start(
  ...
  proxy: socks_proxy,
) do |sftp|
  sftp.download!("/path/to/file")
end

Having issues? Please reach out to our team here.