Excon Proxy Configuration

← Back to Ruby Libraries

Excon is a fast Ruby HTTP client. Pass proxy: with your ProxyMesh URL (see proxy-examples/ruby/excon-proxy.rb). Excon supports sending extra headers on HTTPS CONNECT via :ssl_proxy_headers; reading CONNECT response headers on the origin response is limited—see the ruby-proxy-headers README.

Installation

gem install excon ruby-proxy-headers

Basic Proxy Configuration

require 'excon'

response = Excon.get(
  'https://api.ipify.org?format=json',
  proxy: 'http://username:password@proxyhost:31280',
  ssl_verify_peer: true
)

puts response.body

Custom Proxy Headers

require 'ruby_proxy_headers/excon'

response = RubyProxyHeaders::ExconIntegration.get(
  'https://api.ipify.org?format=json',
  proxy_url: 'http://username:password@proxyhost:31280',
  proxy_connect_headers: { 'X-ProxyMesh-Country' => 'US' }
)
puts response.body

ProxyMesh Headers Reference

Send these headers to control proxy behavior:

  • X-ProxyMesh-Country - Route through a specific country (e.g., "US"). Only works with world proxy or open proxy
  • X-ProxyMesh-IP - Request a specific outgoing IP address
  • X-ProxyMesh-Not-IP - Exclude specific IPs from rotation

The proxy returns X-ProxyMesh-IP with the IP address used for the request (when your stack exposes CONNECT response headers).

Resources

Related Ruby Proxy Guides

Explore proxy configuration for other Ruby HTTP libraries:

Start Free Trial