A caching proxy for the Web supporting HTTP, HTTPS, FTP, and more
224
Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and makes a great server accelerator. It runs on most available operating systems, including Windows and is licensed under the GNU GPL.
services:
squid:
image: easypi/squid
ports:
- "3128:3128/tcp"
- "3130:3130/udp"
volumes:
- ./data/etc/squid.conf:/etc/squid/squid.conf:ro
- ./data/etc/conf.d:/etc/squid/conf.d:ro
- ./data/var:/var/cache/squid
- ./data/log:/var/log/squid
tmpfs:
- /run
stop_signal: SIGKILL
restart: unless-stopped
Tip
- You can mount custom config file as `/etc/squid/squid.conf` - Do not mount entire `./data/etc`, since many files are required in `/etc/squid/` - You need to at least create an empty `./data/etc/conf.d/dummy.conf` - You need to run `squid -z` when `cache_dir ufs` is enabled
$ mkdir -p data/{etc/conf.d,var,log}
$ vim data/etc/squid.conf
$ chmod -R 777 data
$ docker compose run --rm --entrypoint sh squid
>>> id squid
uid=31(squid) gid=31(squid) groups=31(squid),31(squid),101(winbind)
>>> squid -k parse
>>> exit
# init cache dir tree
$ docker compose run --rm squid -z
# start container
$ docker compose up -d
# verify config
$ docker compose exec squid squid -k parse
# reload config (method one)
$ docker compose exec squid squid -k reconfigure
# reload config (method two)
$ docker compose kill -s HUP squid
# cache files
$ find data/var/ -type f
# log files
$ tail -f data/log/*.log
Important
- Files and directories should be accessable by `uid=31,gid=31` - You need to restart container after editing `./data/etc/squid.conf` (see https://github.com/moby/moby/issues/15793)
$ curl -I -x 127.0.0.1:3128 ipinfo.io
HTTP/1.1 200 OK
$ curl -I -x 127.0.0.1:3128 https://ipinfo.io
HTTP/1.1 200 Connection established
HTTP/1.1 200 OK
$ curl -I -x 127.0.0.1:3128 doubleclick.net
HTTP/1.1 403 Forbidden
$ curl -I -x 127.0.0.1:3128 https://doubleclick.net
HTTP/1.1 403 Forbidden
Note
ad-block works as expected!
Content type
Image
Digest
sha256:3d4d013f2…
Size
10.4 MB
Last updated
9 days ago
docker pull easypi/squid