Giter VIP home page Giter VIP logo

docker-squid's Introduction

docker-squid

Docker container for Squid Proxy based on madharjan/docker-base

Squid configuration and Transparent Proxy configuration based on jpetazzo/squid-in-a-can

Changes

  • Squid and iptables in single container
  • Install iptables config if run as Transparent Proxy and cleanup iptables config on container stop

Features

  • Environment variables to set upstream proxy & authentication
  • Environment variables to set cache settings
  • Bats (sstephenson/bats) based test cases

Usages

  • Run docker-squid as Transparent Proxy while docker build to speedup build time by caching OS packages downloads
  • Run docker-squid as Transparent Proxy while docker build behind Corporate Proxy WITHOUT changing Dockerfile (works only if all downloads from Internet is HTTP only, NOT HTTPS)
  • Run docker-squid to conserve bandwidth on slow Internet connection by caching frequently downloaded files

Squid 3.3.8 (docker-squid)

Environment

Variable Default Example
DISABLE_SQUID 0 1 (to disable)
SQUID_INTERFACE_IP 0.0.0.0 170.17.42.1
SQUID_HTTP_PORT 3128 8080
SQUID_INTERCEPT_PORT 3129 8081
SQUID_MAXIMUM_OBJECT_SIZE 1024 512 (MB)
SQUID_DISK_CACHE_SIZE 10000 1000
SQUID_CACHE_PEER_HOST proxyHost
SQUID_CACHE_PEER_PORT proxyPort
SQUID_CACHE_PEER_AUTH user:pass
ENABLE_TRANSPARENT_PROXY 0 1 (to enable)

Build

Clone this project

git clone https://github.com/madharjan/docker-squid
cd docker-squid

Build Container

# login to DockerHub
docker login

# build
make

# tests
make run
make tests
make clean

# tag
make tag_latest

# update Changelog.md
# release
make release

Tag and Commit to Git

git tag 3.3.8
git push origin 3.3.8

Run Container

Squid

Prepare folder on host for container volumes

sudo mkdir -p /opt/docker/squid/cache/
sudo mkdir -p /opt/docker/squid/log/

Run docker-squid

docker stop squid
docker rm squid

docker run -d \
  -p 8080:3128 \
  -e SQUID_CACHE_PEER_HOST=proxyHost \
  -e SQUID_CACHE_PEER_PORT=proxyPort \  
  -v /opt/docker/squid/cache:/var/cache/squid3 \
  -v /opt/docker/squid/log:/var/log/squid3 \
  --name squid \
  madharjan/docker-squid:3.3.8

Run as Transparent Proxy

docker stop squid
docker rm squid

docker run -d \
  --network=host \
  --cap-add=NET_ADMIN \
  -e SQUID_HTTP_PORT=9090 \
  -e SQUID_INTERCEPT_PORT=9091 \
  -e SQUID_CACHE_PEER_HOST=proxyHost \
  -e SQUID_CACHE_PEER_PORT=proxyPort \  
  -e ENABLE_TRANSPARENT_PROXY=1 \
  -v /opt/docker/squid/cache:/var/cache/squid3 \
  -v /opt/docker/squid/log:/var/log/squid3 \
  --name squid \
  madharjan/docker-squid:3.3.8

Systemd Unit File

[Unit]
Description=Squid

After=docker.service

[Service]
TimeoutStartSec=0

ExecStartPre=-/bin/mkdir -p /opt/docker/squid/cache
ExecStartPre=-/bin/mkdir -p /opt/docker/squid/log
ExecStartPre=-/usr/bin/docker stop squid
ExecStartPre=-/usr/bin/docker rm squid
ExecStartPre=-/usr/bin/docker pull madharjan/docker-squid:3.3.8

ExecStart=/usr/bin/docker run \
  -p 8080:3128 \
  -v /opt/docker/squid/cache:/var/cache/squid3 \
  -v /opt/docker/squid/log:/var/log/squid3 \
  --name squid \
  madharjan/docker-squid:3.3.8

ExecStop=/usr/bin/docker stop -t 2 squid

[Install]
WantedBy=multi-user.target

docker-squid's People

Contributors

madharjan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.