cortesi/mitmproxy — pull request #29 by hessu (2012-02-16 14:44:50+00:00)
Title: Reverse proxy mode for mitmproxy

I've added a little bit of code which enables a reverse proxy mode for mitmproxy. This pull request contains two commits to bring that to the master.

When run with the option "-R localhost:80", mitmproxy will accept a non-proxy-mode HTTP request ("GET / HTTP/1.0"), set scheme to http and host/port to localhost:80, and the proxy connection will then be made to the correct server.

The code still assumes that the client will transmit the correct Host: header that the upstream/origin server will accept as it's own (name-based virtual hosts), and will not tamper with that header, but that can probably be "fixed" elsewhere if needed.

I have not even tried to figure out how this copes with https, sorry for my ignorance. But it should still be useful for many - it's a very handy tool for debugging client requests when you have access to the server (or a box in between) but it'd be hard to add proxy configuration to the client.