Table of Contents

About

This docker build file is for socks-router developed by the computer security department of Stuttgart University, a program meant to route connections to upstream proxy servers depending on the host header of a HTTP request.

Usage

Download the file Dockerfile to an empty directory and issue:

docker build -t TAG .

where:

Source

FROM debian:stable-slim
 
# update package manager
RUN  apt-get update -y && \
     apt-get upgrade -y && \
     apt-get dist-upgrade -y && \
     apt-get -y autoremove && \
     apt-get clean
 
# install required packages
RUN apt-get install -y \
    expect \
    telnet \
    coreutils \
    bash \
    curl \
    git \
    build-essential \
    distcc \
    autoconf \
    automake \
    libtool \
    pkgconf \
    libevent-dev \
    libssl-dev \
    libzstd-dev \
    liblzma-dev \
    zlib1g \
    zlib1g-dev 
 
# install the latest golang and socks router
WORKDIR /tmp
RUN curl -fsSL "https://go.dev/dl/$(curl -s 'https://go.dev/VERSION?m=text' | head -1).linux-amd64.tar.gz" -o go.tar.gz && \
    tar -xzf go.tar.gz && \
    rm go.tar.gz && \
    mkdir -p /usr/local/bin/ && \
    export GOPATH=/tmp/ && \
    /tmp/go/bin/go install github.com/rus-cert/socks-router@latest && \
    cp /tmp/bin/socks-router /usr/local/bin/ && \
    printf "10.40.40.0/24\tsocks5://127.0.0.1:2080\n.example.com\tsocks5://127.0.0.1:2080\n" >/etc/socks-router.routes && \
    rm -rf /tmp/go
 
# remove packages that will not be used
WORKDIR /
RUN apt-get purge -y \
        curl \
        git \
        build-essential \
        autoconf \
        automake \
        libtool \
        pkgconf && \
    apt-get autoremove -y 
 
# add filesystem requirements
ADD rootfs /
 
# execute the bootstrapper that will start tor
ENTRYPOINT [ "/bin/bash", "/usr/local/bin/run" ]

/usr/local/bin/run

#!/bin/bash
 
if [ ! -f /data/socks-router.routes ]; then
    cp /etc/socks-router.routes /data/
fi
 
/usr/local/bin/socks-router --config /data/socks-router.routes --listen 0.0.0.0:1080