Skip to content

Ruby

You will first need your Proxy Credentials so make sure you can find them in the dashboard

Credentials

Making Proxied TCP Connections

Port Leases

If your software does not natively support SOCKS proxies, one option you have is to leverage Noble Port leases. For example if you wanted to connect to a MongoDB database:

ruby
require 'mongo'
require 'net/http'
require 'json'

# Create a lease by making a POST request
uri = URI('https://api.noble-ip.com/v1/leases')
lease_params = {
  target_host: 'mongodb.mycompany.com',
  target_port: 27017,
  proxy_token: 'fp_PROXYTOKEN'
}
lease_response = Net::HTTP.post(uri, lease_params.to_json, 'Content-Type' => 'application/json')
lease = JSON.parse(lease_response.body)

# Connect to the MongoDB server
client = Mongo::Client.new("mongodb://#{lease['hostname']}:#{lease['port']}/")

# Access a specific database
db = client[:mydatabase]

Making Proxied HTTP/HTTPs Requests

if you need to access a service over HTTP via a static IP, you can leverage the HTTPS proxies.

Then you can leverage a HTTP library like requests to make API calls:

ruby
require 'httparty'

proxy = URI("https://noble:fp_NOBLETOKEN@p-12345.noble-ip.com:3129")

options = {
  http_proxyaddr: proxy.host,
  http_proxyport: proxy.port,
  http_proxyuser: proxy.user,
  http_proxypass: proxy.password
}

response = HTTParty.get('https://example.com', options)
puts response.body