1. Set HTTP Proxy to Ruby

Net::HTTP will automatically create a proxy from the http_proxy environment variable if it is present.

So you can use:

ENV['http_proxy'] = '' # your http://address:port here

and Net::HTTP will use it for all requests by default.


2. Install Proxyman Certificate on Ruby

By default, Ruby on macOS might not trust Proxyman self-signed certificate. As a result, you might encounter SSL Error if you try to intercept HTTPS traffic.

You can explicitly tell Ruby to use Proxyman Certificate by using SSL_CERT_FILE env.

$ env SSL_CERT_FILE=~/.proxyman/proxyman-ca.pem ruby my_script.rb