Skip to content

Instantly share code, notes, and snippets.

@JingyZhu
Last active January 7, 2025 18:35
Show Gist options
  • Save JingyZhu/41bc13e15bb032751063c5b31cadbfc0 to your computer and use it in GitHub Desktop.
Save JingyZhu/41bc13e15bb032751063c5b31cadbfc0 to your computer and use it in GitHub Desktop.
Build a docker for tinyproxy with customized whitelist
#!/bin/bash
PORT=${PORT:-8888}
ALLOWIPS=${ALLOWIPS}
ALLOWSTR=$(echo ${ALLOWIPS} | sed 's/:/\nAllow /')
if [[ "$ALLOWSTR" ]]; then
ALLOWSTR="Allow ${ALLOWSTR}"
fi
echo """Port ${PORT}
Timeout 600
DefaultErrorFile \"/usr/local/share/tinyproxy/default.html\"
StatFile \"/usr/local/share/tinyproxy/stats.html\"
LogLevel Info
MaxClients 100
Allow 127.0.0.1
${ALLOWSTR}
Allow ::1
ConnectPort 443
ConnectPort 563
""" > tinyproxy.conf
nohup tinyproxy -c ./tinyproxy.conf -d > tinyproxy.log
FROM ubuntu
RUN mkdir -p /home/tinyproxy
COPY . /home/tinyproxy
WORKDIR /home/tinyproxy
RUN apt update && apt install -y build-essential
RUN ./autogen.sh
RUN ./configure
RUN make && make install
ENTRYPOINT [ "./docker-entrypoint.sh" ]

How to build image

  • cp Dockerfile and docker-entrypoint.sh to top directory of tinyproxy
  • Build docker image with Dockerfile
  • Run container: docker run --rm -d -p ${HostPort}:${ContainerPort} -e ALLOWIPS=${ALLOWIPs} -e PORT=${ContainerPort} --name tinyproxy tinyproxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment