Search code examples
nginxtraefikmitmproxy

mitmproxy in docker between traefik and service


I'd like to analize the traffic placing mimtproxy between the load balancer (traefik or nginx) and the service but I can't really understand how to do that. I don't want to set mitmproxy as ordinary proxy (that works like a charm) as I'd like to understand how the load balancers modify the requests.

I read the documentation on available mode of operation but I didn't recognize which situation suits me. I tend to exclude transparent mode (that I used on firewalls) and I don't really understand what is the --mode reverse:http://...: I thought it was a way to forward anything to the given address, so I tried it setting:

  mitmweb:
    image: mitmproxy/mitmproxy
    tty: true
    ports:
      - "8080:8080"  # proxy                                                                                                            
      - "8081:8081"  # web-interface                                                                                                    
    command: mitmweb --web-host 0.0.0.0 --no-web-open-browser -p 8080 --mode reverse:http://django:8000/
   ...

but mitmproxy complains that

403: To protect against DNS rebinding, mitmweb can only be accessed by IP at the moment. (https://github.com/mitmproxy/mitmproxy/issues/3234)

Is it any possible and how?


Solution

  • I misinterpreted the message that was not refusing to proxy. It just hinted me that I needed to access the web interface via an ip rather than a dns name.

    The result is awesome. You get the traffic and can introspect the request/response cicle in a very useful way.