DEV Community

Discussion on: Squid in docker, help please

Collapse
 
argenis72907512 profile image
argenis

Hello,

Use my config.This work fine.

Dockerfile


FROM alpine:latest
LABEL maintainer="linux8a@gmail.com"

RUN apk update \
&& apk add squid curl bash which \
&& rm -rf /var/cache/apk/*

COPY start-squid.sh /usr/local/bin/
RUN chmod 755 /usr/local/bin/start-squid.sh
EXPOSE 3128/tcp
ENTRYPOINT ["/usr/local/bin/start-squid.sh"]


start-squid.sh


!/bin/bash

set -e

if [[ ${1:0:1} = '-' ]]; then
EXTRA_ARGS="$@"
set --
elif [[ ${1} == squid || ${1} == $(which squid) ]]; then
EXTRA_ARGS="${@:2}"
set --
fi

if [[ -z ${1} ]]; then
if [[ ! -d ${SQUID_CACHE_DIR}/00 ]]; then
echo "Initializing cache..."
$(which squid) -N -f /etc/squid/squid.conf -z
fi
echo "Starting squid..."
exec $(which squid) -f /etc/squid/squid.conf -NYCd 1 ${EXTRA_ARGS}
else
exec "$@"
fi


Squid.conf


acl localnet src 10.0.0.0/8
acl localnet src 172.16.0.0/12

acl localnet src 192.168.0.0/16
acl localnet src fc00::/7

acl localnet src fe80::/10

acl SSL_ports port 443
acl Safe_ports port 80

acl Safe_ports port 21

acl Safe_ports port 443
acl Safe_ports port 70

acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280

acl Safe_ports port 488

acl Safe_ports port 591

acl Safe_ports port 777

acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
cache_mem 512 MB
coredump_dir /var/cache/squid

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

dns_nameservers 1.1.1.1 8.8.8.8


Docker-compose.yml


version: '3.1'

services:
squid:
image: squid
container_name: squid
ports:
- "3128:3128"
volumes:
- ./squid/cache:/var/spool/squid
- ./etc/squid.conf:/etc/squid/squid.conf:ro
- ./squid/log:/var/log/squid:rw
restart: always
volumes:
squid:


Regards

Collapse
 
gor2d profile image
Egor Shamanskiy

many thanks)))