vi docker-compose.yml
services: squid: image: ubuntu/squid:latest hostname: squid container_name: squid environment: - TZ=Asia/Taipei ports: - 3128:3128 # volumes: # - './conf/squid.conf:/etc/squid/squid.conf:ro' # - './conf/passwords:/etc/squid/passwords:ro' restart: always
docker compose up -d
mkdir -p conf docker cp squid:/etc/squid/squid.conf ./conf/
services: squid: image: ubuntu/squid:latest hostname: squid container_name: squid environment: - TZ=Asia/Taipei ports: - 3128:3128 volumes: - './conf/squid.conf:/etc/squid/squid.conf:ro' # - './conf/passwords:/etc/squid/passwords:ro' restart: always
vi ./conf/squid.conf
: acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl SSL_ports port 443 8006 acl Safe_ports port 8006 # PVE manager acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https : # For example, to allow access from your local networks, you may uncomment the # following rule (and/or add rules that match your definition of "local"): http_access allow localnet :
docker compose restart
services: squid: image: ubuntu/squid:latest hostname: squid container_name: squid environment: - TZ=Asia/Taipei extra_hosts: - "www.ichiayi.com:192.168.11.133" - "web.ichiayi.com:192.168.11.134" ports: - 3128:3128 volumes: - './conf/squid.conf:/etc/squid/squid.conf:ro' # - './conf/passwords:/etc/squid/passwords:ro' restart: always
docker compose up -d
以下是在 CentOS 7 與 Ubuntu 20.04 底下安裝與設定 Squid Proxy Server
sudo -i apt install squid apt list -a squid
root@iiidevops1:~# apt list -a squid Listing... Done squid/focal-updates,focal-security,now 4.10-1ubuntu1.2 amd64 [installed] squid/focal 4.10-1ubuntu1 amd64
su - root yum install -y squid httpd-tools
[root@ct-squid ~]# rpm -q squid squid-3.5.20-12.el7.x86_64
: ftp_user [email protected] : acl SSL_ports port 443 7443 : acl Safe_ports port 443 # https acl Safe_ports port 7443 # https-g2b2c acl Safe_ports port 5222 # GoogleTalk : acl our_networks src 61.67.71.0/24 220.130.131.238/32 http_access allow our_networks :
: # all networks acl all_networks src all : # allow all http_access allow all_networks # And finally deny all other access to this proxy :
vi /etc/squid/squid.conf
: auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd : acl password proxy_auth REQUIRED http_access allow password :
htpasswd -c /etc/squid/passwd jonathan
htpasswd /etc/squid/passwd tryweb
systemctl restart squid.service systemctl enable squid.service