Logging with an HTTP Proxy

Simple MITM debugging

Published January 22, 2021

proxy, debugging

I miss having Chrome dev tools when writing node applications, since I often want to see what exactly the network traffic. Here's a way to easily setup a man in the middle proxy to look at all the traffic your application is generating.

Run the docker instance

First we first up the proxy with the web interface:

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

Node ENV Variables

Then we set the proxy environment variable, and for node specifically, tell it to not worry about self-signed certificates:

1
2
  export HTTP_PROXY=http://localhost:8080
  export NODE_TLS_REJECT_UNAUTHORIZED='0'

Then we run our script:

1
  node outdated.js

Then go visit http://localhost:8081 to see all of the requests that were made.

Simple and easy.

Previously

ankane/blazer

2020-12-04

Next

mayfrost/guides

2021-02-02

labnotes

Previously

rails uuid primary key Slightly more obscure

2020-11-22

Next

Docker One Liners Why install

2021-02-12