I have the following docker-compose:
version: '3'
services:
mitmproxy:
image: johnmccabe/mitmweb
container_name: mitmproxy
command: --cadir /ca --wiface 0.0.0.0
restart: always
ports:
#- "8080:8080"
- "8081:8081"
python:
image: python
build: ./python-socks-example
command: python3 /home/project/socks-example.py
volumes:
- ./python-socks-example:/home/project/
depends_on:
- mitmproxy
container_name: python
restart: always
I want my python HTTP requests to go through mitmproxy on the other container. Here's the python code:
import requests
import time
while(True):
time.sleep(5)
print("gonna connect")
resp = requests.get('http://google.com',
proxies=dict(http='socks5://user:[email protected]:8080',
https='socks5://user:[email protected]:8080'))
print(resp)
print("done")
time.sleep(2)
How can I wire the network of python
to go through mitmproxy
container?
In your python code, you'll need to reference the other service.
The proxy URL should be updated to have the right hostname. Which is to say replacing
server.com
with the name of of the service offering whatever you're trying to connect to.In this case, you'd replace
server.com
withmitmproxy
.Meaning your python code would look as such: