├── startup.sh ├── README.md └── Dockerfile /startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ -z "${TOR_INSTANCES}" ]]; then 4 | TOR_INSTANCE_COUNT=5 5 | echo "Environment variable TOR_INSTANCES not specified, defaulting to 5" 6 | else 7 | TOR_INSTANCE_COUNT="${TOR_INSTANCES}" 8 | fi 9 | 10 | re='^[0-9]+$' 11 | if ! [[ $TOR_INSTANCE_COUNT =~ $re ]] ; then 12 | echo "error: TOR_INSTANCES is not a number, defaulting to 5" 13 | TOR_INSTANCE_COUNT=5 14 | fi 15 | 16 | 17 | multitor --init $TOR_INSTANCE_COUNT --user root --socks-port 9000 --control-port 9900 --proxy privoxy --haproxy --verbose --debug > /tmp/multitor.log; tail -f /tmp/multitor.log -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-multitor 2 | 3 | This is an Alpine Docker image that runs multitor. Multitor creates a Proxy with multiple TOR instances wich are load-balanced. For detailed information about multitor, check out https://github.com/trimstray/multitor . 4 | 5 | # Build 6 | git clone https://github.com/evait-security/docker-multitor 7 | 8 | cd docker-multitor 9 | 10 | docker build -t multitor . 11 | 12 | # Quick Start 13 | 14 | ```bash 15 | # By default, the container runs with 5 Tor instances, HAProxy (frontend) and Privoxy (broker), which implicate the load balancer. The proxy is set up with port 16379 and the container will be removed after use. 16 | 17 | docker run --rm -p 16379:16379 evait/multitor 18 | 19 | # Start 20 tor instances 20 | docker run --rm -e "TOR_INSTANCES=20" -p 16379:16379 evait/multitor 21 | ``` 22 | 23 | # Advance 24 | 25 | You can also start the container interactively 26 | 27 | ```bash 28 | # run interactive 29 | docker run --name multitor -it -p 16379:16379 evait/multitor /bin/bash 30 | # start multitor inside the container 31 | multitor --init 5 --user root --socks-port 9000 --control-port 9900 --proxy privoxy --haproxy 32 | ``` 33 | 34 | For detailed information on how multitor works and what options it provides, check out the multitor wiki https://github.com/trimstray/multitor/wiki/Manual 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | ENV BUILD_PACKAGES="build-base openssl" \ 4 | PACKAGES="tor sudo bash git haproxy privoxy npm procps" 5 | 6 | # install requirements 7 | RUN \ 8 | apk update && apk add --no-cache $BUILD_PACKAGES $PACKAGES && \ 9 | npm install -g http-proxy-to-socks 10 | 11 | # fix certificate problem (avoid con reset by peer) 12 | RUN \ 13 | apk add ca-certificates wget && \ 14 | update-ca-certificates 15 | 16 | # install polipo 17 | RUN \ 18 | wget https://github.com/jech/polipo/archive/master.zip -O polipo.zip && \ 19 | unzip polipo.zip && \ 20 | cd polipo-master && \ 21 | make && \ 22 | install polipo /usr/local/bin/ && \ 23 | cd .. && \ 24 | rm -rf polipo.zip polipo-master && \ 25 | mkdir -p /usr/share/polipo/www /var/cache/polipo 26 | 27 | # clean build packages 28 | RUN \ 29 | apk del $BUILD_PACKAGES 30 | 31 | # install multitor 32 | RUN git clone https://github.com/trimstray/multitor && \ 33 | cd multitor && \ 34 | ./setup.sh install && \ 35 | # create log folders 36 | mkdir -p /var/log/multitor/privoxy/ && \ 37 | mkdir -p /var/log/polipo/ && \ 38 | # let haproxy listen from outside, instand only in the docker container 39 | sed -i s/127.0.0.1:16379/0.0.0.0:16379/g templates/haproxy-template.cfg 40 | 41 | COPY startup.sh /multitor/ 42 | RUN chmod +x /multitor/startup.sh 43 | 44 | WORKDIR /multitor/ 45 | EXPOSE 16379 46 | 47 | #CMD multitor --init 5 --user root --socks-port 9000 --control-port 9900 --proxy privoxy --haproxy --verbose --debug > /tmp/multitor.log; tail -f /tmp/multitor.log 48 | CMD ["./startup.sh"] --------------------------------------------------------------------------------