mitmproxy / mitmproxy

An interactive TLS-capable intercepting HTTP proxy for penetration testers and software developers.
https://mitmproxy.org
MIT License
36.72k stars 4.03k forks source link

mitmproxy doesn't work well on RHEL8 #4759

Closed k19810703 closed 3 years ago

k19810703 commented 3 years ago

Problem Description

mitmproxy doesn't work well on RHEL8.

When I use localhost as proxy , it works well.

$ curl -x http://localhost:8880/ -i http://www.baidu.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: keep-alive
Content-Length: 2381
Content-Type: text/html
Date: Mon, 16 Aug 2021 01:59:44 GMT
Etag: "588604ec-94d"
Last-Modified: Mon, 23 Jan 2017 13:28:12 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/

But if I use my IP , it doesn't work

$ curl -x http://myip:8880/ -H 'Expect:' -iv http://www.baidu.com
* Rebuilt URL to: http://www.baidu.com/
*   Trying 9.197.12.29...
* TCP_NODELAY set
* Connected to 9.197.12.29 (9.197.12.29) port 8880 (#0)
> GET http://www.baidu.com/ HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/7.61.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
* Empty reply from server
* Connection #0 to host 9.197.12.29 left intact
curl: (52) Empty reply from server

Steps to reproduce the behavior:

  1. start mitmproxy using docker
    docker run --rm --name dev01proxy -d -it -p 8880:8080 -p 8881:8081  mitmproxy/mitmproxy mitmweb --web-host 0.0.0.0 --set ssl_insecure=true 
  2. curl using localhost as proxy
    curl -x http://localhost:8880/ -i http://www.baidu.com
  3. curl using ip as proxy
    curl -x http://myip:8880/ -H 'Expect:' -iv http://www.baidu.com

    System Information

    root@64e7c877fcc9:/# mitmproxy --version Mitmproxy: 7.0.2 Python: 3.9.6 OpenSSL: OpenSSL 1.1.1k 25 Mar 2021 Platform: Linux-4.18.0-240.1.1.el8_3.x86_64-x86_64-with-glibc2.28

mhils commented 3 years ago

We just open a regular listening socket and do nothing fancy. I suspect this is a Docker networking problem, not a mitmproxy one?

k19810703 commented 3 years ago

@mhils I tried to install mitmproxy via pipx on RHEL, same error happened.

Is there any additional setting required on RHEL?

BTW, on MAC , every thins goes well

mhils commented 3 years ago

I don't really know anything about RHEL, sorry. 🤷‍♂️