Skip to content

jfastnacht/ddev-mitmproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

add-on registry tests last commit release

DDEV mitmproxy

Overview

This add-on integrates mitmproxy into your DDEV project.

Installation

ddev add-on get jfastnacht/ddev-mitmproxy
ddev restart

After installation, make sure to commit the .ddev directory to version control.

Configuration

Basic

Set the proxy configuration for your web container in docker-compose.web_extra.yaml or for whatever other service you run:

services:
  web:
    environment:
      - http_proxy=http://mitmproxy:8080/
      - no_proxy=localhost,127.0.0.1
      - HTTP_PROXY=http://mitmproxy:8080/
      - HTTPS_PROXY=http://mitmproxy:8080/
      - SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

You might have to add more IPs/domains to your no_proxy configuration, if you don't want specific traffic to go through mitmproxy.

HTTPS

Important

If you have set the proxy configuration for HTTPS, it is necessary to run this hook before any connection is made.

If you want to use HTTPS, you have to install the certificates on the web container, e.g. config.mitmproxy.yaml:

hooks:
  post-start:
    - exec: "wget http://mitm.it/cert/pem -O /usr/local/share/ca-certificates/mitmproxy.crt"
    - exec: "sudo update-ca-certificates"

If you want to use HTTPS in any other container, you might have to adjust this example according to your needs:

hooks:
  post-start:
    - exec-host: "ddev exec -s myservice wget http://mitm.it/cert/pem -O /usr/local/share/ca-certificates/mitmproxy.crt"
    - exec-host: "ddev exec -s myservice sudo update-ca-certificates"

Application

You probably have to set up proxies for your PHP application or other services as well. A simple example would be:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_PROXY, "mitmproxy:8080");
curl_setopt($ch, CURLOPT_URL, "https://github.com");
curl_exec($ch);
curl_close($ch);

Usage

Command Description
ddev describe View service status and used ports for mitmproxy
ddev logs -s mitmproxy Check mitmproxy logs

Advanced Customization

To change the Docker image:

ddev dotenv set .ddev/.env.mitmproxy --mitmproxy-docker-image="mitmproxy/mitmproxy:latest"
ddev add-on get jfastnacht/ddev-mitmproxy
ddev restart

Make sure to commit the .ddev/.env.mitmproxy file to version control.

All customization options (use with caution):

Variable Flag Default
MITMPROXY_DOCKER_IMAGE --mitmproxy-docker-image mitmproxy/mitmproxy:latest
MITMPROXY_PASSWORD --mitmproxy-password mitm

Credits

Contributed and maintained by @jfastnacht

About

Use mitmproxy to catch and analyze outgoing HTTP/HTTPS traffic within ddev

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Generated from ddev/ddev-addon-template