mitmproxy / docker-releases

🗃️ This repository has been integrated into mitmproxy/mitmproxy.
52 stars 26 forks source link

Mitmweb Process Only Listens to Localhost #19

Closed lknhd closed 6 years ago

lknhd commented 7 years ago

Hi, I'm trying to run mitmproxy and mitmweb via docker, but I found out that mitmweb only listens on localhost inside the container. This makes it imposible to forward the traffic via docker proxy using this command:

$ docker run --rm -it -p 8080:8080 -p 127.0.0.1:8081:8081 mitmproxy/mitmproxy mitmweb
mhils commented 7 years ago

I found out that mitmweb only listens on localhost inside the container

Are you referring to the web interface or to the proxy funtionality?

lknhd commented 7 years ago

Are you referring to the web interface or to the proxy funtionality?

the web interface

lknhd commented 7 years ago

So heres more information.

# docker run --name mitmproxy -it -p 8080:8080 -p 8081:8081 mitmproxy/mitmproxy mitmweb
# docker ps
CONTAINER ID        IMAGE                                                          COMMAND                  CREATED             STATUS              PORTS                              NAMES
9fd00458a038        mitmproxy/mitmproxy:latest                                     "docker-entrypoint.sh"   12 seconds ago      Up 12 seconds       0.0.0.0:8080-8081->8080-8081/tcp   mitmproxy

When I curl to localhost:8081

# curl localhost:8081
curl: (56) Recv failure: Connection reset by peer

Then I check the the listened port using netstat

# docker exec -it mitmproxy netstat -ntlup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:8081          0.0.0.0:*               LISTEN      -

I know I can actually run the container with flag --net=host, but I actually wanted to share the mitmweb through the network. I think it will be more convinient if the mitmweb process just listen to address 0.0.0.0 instead of localhost.

mlebkowski commented 7 years ago

Just ran into this issue myself. For now, you can use --web-iface 0.0.0.0 as an ad-hoc fix