Skip to content
Search

Mitmproxy

lastmod 2025-05-14created 2021-07-1713 edits

Open-source HTTPS Proxy for intercepting, modifying, and replaying web traffic such as HTTP 1/2, WebSocket, and SSL/TLS

Features

  • Provides CLI + Web UI + Python API, with a powerful ecosystem
  • New features in 7.0
    • Full TCP support (protocols like SMTP)
    • HTTP/1 and HTTP/2 interoperability: connect HTTP/2 clients to HTTP/1 servers
    • Support for displaying WebSocket messages in the UI
    • Secure Web Proxy (TLS-over-TLS)
    • Console UI support on Windows as well
  • 8.0 improvements
    • Web UI improvements: rendering of TCP / WebSocket flows, support for cURL/HTTPie/Raw HTTP Export
    • Async Event Hook support
    • New TLS Event Hook support (TLS Handshake success/failure)
    • SOCKS v5 authentication support

Usage

To change the port:

mitmproxy -p 9999

Docker Usage

To launch the terminal user interface of mitmproxy:

$ docker run --rm -it -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy -p 8080:8080 mitmproxy/mitmproxy

NOTE

The volume mount -v is optional. It lets you persist and reuse the generated CA certificates between runs, and gives you access to those certificates. Otherwise, a new root CA is generated each time the container restarts.

Once started, mitmproxy listens as an HTTP proxy on localhost:8080:

$ http_proxy=http://localhost:8080/ curl http://example.com/
$ https_proxy=http://localhost:8080/ curl -k https://example.com/         # `-k` 옵션 주목

INFORMATION

Note that lowercase is used when using it with curl.

You can also start mitmdump by just adding that to the end of the command-line:

$ docker run --rm -it -p 8080:8080 mitmproxy/mitmproxy mitmdump

For mitmweb, you also need to expose port 8081:

$ docker run --rm -it -p 8080:8080 -p 127.0.0.1:8081:8081 mitmproxy/mitmproxy mitmweb --web-host 0.0.0.0

You can also pass options directly via the CLI:

$ docker run --rm -it -p 8080:8080 mitmproxy/mitmproxy mitmdump --set ssl_insecure=true

If ~/.mitmproxy/mitmproxy-ca.pem is present in the container, mitmproxy will assume uid and gid from the file owner. For further details, please consult the mitmproxy documentation.

Caveats when using Docker

Going through the Proxy, the request ends up being re-sent from Docker to the target server, so if you use something like localhost as the URL, the Guest OS makes a localhost loopback request. Therefore you must type the Host PC's IP directly.

http_proxy=http://localhost:8080/ curl http://<HOST_IP>/

Connecting via reverse tunneling

See OpenSSH#Connecting via reverse tunneling.

See also

Favorite site

author Zer0 sitemap