| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This dockerfile builds a Squid 4 instance and includes all the necessary tooling to run it as a MITM (man-in-the-middle) SSL proxy.
There's a number of reasons to do this - the big one being optimizing caching and delivery of objects during docker builds which might be downloading them from SSL protected endpoints.
It will require you to generate your own CA and set it as trusted.
The resulting docker image uses the following configuration environment variables:
By default squid in SSL MITM mode treats cache_peer entries quite differently. Because squid unwraps the CONNECT statement when bumping an SSL connection, but does not rewrap it when communicating with peers, it requires all peers to connect with SSL as well. This breaks compatibility with simple minded proxies.
To work around this, proxychains-ng (proxychains4 internally) is built and included in this image. If you need to use an upstream proxy with a MITM squid4, you should launch the image in proxychains mode which intercepts squids direct outbound connections and redirects them via CONNECT requests. This also adds SOCKS4 and SOCKS5 proxy support if so desired.
proxychains is configured with the following environment variables. As with the others above, CONFIG_DISABLE prevents overwriting templated files.
In some corporate environments, its not possible to get reliable DNS outbound service and proxychains-ng's DNS support won't be able to provide for Squid4 to actually work. To address this, configuration is included to setup and use DNS-over-HTTPS.
The idea of the DNS-over-HTTPS client is that it will use your local proxy and network access to provide DNS service to Squid4.
Since the DNS-over-HTTPS daemon is a separate Go binary, you may also need to specify your internal proxy as an upstream to allow it to contact the HTTPS DNS server - do this by passing the standard http_proxy and https_proxy parameters. Most likely these will be the same as your PROXYCHAIN_PROXYx directives (and probably only the 1).
The following command line will get you up and running quickly. It presumes you've generated a suitable CA certificate and are intending to use the proxy as a local MITM on your machine:
sudo mkdir -p /srv/squid/cache
docker run -it -p 3128:127.0.0.1:3128 --rm \
-v /srv/squid/cache:/var/cache/squid4 \
-v /etc/ssl/certs:/etc/ssl/certs:ro \
-v /etc/ssl/private/local_mitm.pem:/local-mitm.pem:ro \
-v /etc/ssl/certs/local_mitm.pem:/local-mitm.crt:ro \
-e MITM_CERT=/local-mitm.crt \
-e MITM_KEY=/local-mitm.pem \
-e MITM_PROXY=yes \
squid
Note that it doesn't really matter where we mount the certificate - the image launch script makes a copy as root to avoid messing with permissions anyway.
This is an example of a systemd unit file to persistly start squid4:
[Unit]
Description=Squid4 Docker Container
Documentation=http://wiki.squid.org
After=network.target docker.service
Requires=docker.service
[Service]
ExecStartPre=-/usr/bin/docker kill squid4
ExecStartPre=-/usr/bin/docker rm squid4
ExecStart=/usr/bin/docker run --net=host --rm \
-v /srv/squid/cache:/var/cache/squid4 \
-v /etc/ssl/certs:/etc/ssl/certs:ro \
-v /etc/ssl/private/local_mitm.pem:/local_mitm.pem:ro \
-v /etc/ssl/certs/local_mitm.pem:/local_mitm.crt:ro \
-e MITM_KEY=/local_mitm.pem \
-e MITM_CERT=/local_mitm.crt \
-e MITM_PROXY=yes \
--name squid4 \
squid
[Install]
WantedBy=multi-user.target
| Back | FazBrowse Home | New Git URL |