Excon Proxy Configuration
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 proxyX-ProxyMesh-IP- Request a specific outgoing IP addressX-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
- Excon Documentation
- Excon on RubyGems
- Excon on RubyDoc
- ruby-proxy-headers (Excon)
- ruby-proxy-headers on RubyGems
- ruby-proxy-headers on RubyDoc
- ProxyMesh Headers Reference
- Example Code on GitHub
Related Ruby Proxy Guides
Explore proxy configuration for other Ruby HTTP libraries: