I'm looking for a way to simply set up a proxy locally that connects to a remote site. I don't want to install anything in the system proper. If I could call it with a single command-line call rather than mucking with even a single config file, that would be brilliant.
The purpose is to sniff the traffic between my local app, which I am developing, and the remote server, which someone else is providing and which uses HTTPS.
Preferably it would be a Ruby, Python or Node package, so that I could just do something along the lines of:
mkdir simplest-proxy; cd simplest-proxy; bundle init
echo "gem 'simplest-proxy'" >> Gemfile; bundle --path vendor/bundle
bundle exec bin/simplest-proxy -p 8080 https://remote.site.example.com/
or
virtualenv simplest-proxy; cd simplest-proxy
bin/easy_install simplest-proxy
bin/simplest-proxy -p 8080 https://remote.site.example.com/
or
mkdir simplest-proxy; cd simplest-proxy
npm install simplest-proxy
node_modules/.bin/simplest-proxy -p 8080 https://remote.site.example.com/
It would allow my app to connect to localhost:8080
, which would forward the request (and rewrite the Host
header and whatever else necessary) to the remote site. I would be able to watch lo
in WireShark and find out what's going on.
I've had a quick look around in pypi, rubygems and npm, but what I found so far was either not working (proxylet
, which otherwise looked very promising), intended for a much more complicated scenario and requiring setup (dj-revproxy
) or expecting to be called with a correct Host
(node-reverse-proxy
) rather than rewriting.
UPDATE: I'm going with an Apache with a ProxyPass
/ ProxyPassReverse
config for now, but it feels massively overkill and requires playing with config files.
UPDATE: Another solution that is not applicable is an actual HTTP proxy rather than one emulating the remote site. Because the remote site is an HTTPS site, that would just make my app do a CONNECT within the proxy and nothing has been gained.
Found http://mitmproxy.org/ !
My use case is covered by:
mitmproxy -p 8080 -P https://remote.site.example.com/
But there's more. It also offers an ncurses UI for showing all requests done, and allows you to inspect them. This makes WireShark unnecessary.
Install with your distro package installer or with easy_install as shown in the question:
virtualenv mitmproxy; cd mitmproxy
bin/easy_install mitmproxy
bin/mitmproxy -p 8080 -P https://remote.site.example.com/
Edit:
For mitmproxy version 3, the arguments would be:
mitmproxy -p 8080 --mode reverse:https://remote.site.example.com/