A complete CLI MITM proxy example demonstrating all features of the proxy package. It prints intercepted traffic (HTTP, WebSocket, TCP) to stdout.
go run main.goThe proxy listens on 0.0.0.0:8080. Configure your browser or system proxy to point here.
# Linux
GOOS=linux GOARCH=amd64 go build -o proxy main.go
# Windows
GOOS=windows GOARCH=amd64 go build -o proxy.exe main.go
# macOS
GOOS=darwin GOARCH=amd64 go build -o proxy main.goThis example hooks all four matcher types to log traffic:
| Matcher | Purpose |
|---|---|
WithReqMatcher |
Logs HTTP requests |
WithRespMatcher |
Logs HTTP responses |
WithWsMatcher |
Logs WebSocket frames (handles unmasking) |
WithRawMatcher |
Logs raw TCP data |
The tool uses the embedded development CA certificate (proxy.Certificate + proxy.PrivateKey). For production, replace with your own CA or use proxy.FromSelfSigned().
To chain an upstream proxy, set conf.Dialer before ListenAndServe:
dialer, _ := proxy.SOCKS5("tcp", "127.0.0.1:10808", nil, nil)
conf.Dialer = dialer- Default log level is
TraceLevelto show all details - Client-side TLS verification is disabled (
InsecureSkipVerify = true) - Default SNI fallback:
www.google.com