I'm new to mitmproxy and and I'm probably doing something wrong.
I'm running Mitmproxy in transparent mode on Ubuntu and followed the steps on https://docs.mitmproxy.org/stable/howto-transparent/. Its IP is 10.50.10.117.
I then added a line to /etc/hosts in my client machine (10.50.10.116) that points to the mitmproxy server for a test domain (example.com). So this is only on the client machine, and not on the machine running mitmproxy.
Then when I execute 'curl http://example.com' on the client machine, I see the request get to mitmproxy but it errors out with:
10.50.10.116:60936: GET http://example.com/
Host: example.com
User-Agent: curl/7.68.0
Accept: */*
<< Server connection to ('10.50.10.117', 80) failed: Error connecting to "10.50.10.117": [Errno 111] Connection refused
So mitmproxy is trying to connect to its own host on port 80. Why is it not proxying the request to the real example.com?
Thanks.
Henry
https://docs.mitmproxy.org/stable/concepts-modes/#transparent-proxy has an illustration that shows your problem: The TCP packet's destination IP address is mitmproxy and not the actual target. Transparent mode expects Layer 2 redirection.
It looks like you want to run mitmproxy as a reverse proxy. Alternatively, starting with mitmproxy 7 (currently only available as development snapshots, but I encourage you to try them out), you can run it in regular mode and it will pick up host headers for the target information.