目錄表

Squid Proxy Server 安裝設定

使用 docker compose 方式

  1. 將 squid.conf 掛出來進行後續設定編輯

    mkdir -p conf
    docker cp squid:/etc/squid/squid.conf ./conf/

  2. 修改 docker-compose.yml
    version: '3'
    services:
      squid:
        image: elestio/squid:latest
        hostname: squid
        container_name: squid
        environment:
          - SQUID_CONFIG_FILE=/etc/squid/squid.conf
        ports:
          - 3128:3128
        volumes:
          - './conf/squid.conf:/etc/squid/squid.conf:ro'
        #   - './conf/passwords:/etc/squid/passwords:ro'
        restart: always
  3. 修改 squid.conf

    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 方式

一般安裝程序

以下是在 CentOS 7 與 Ubuntu 20.04 底下安裝與設定 Squid Proxy Server

Ubuntu 20.04

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

CentOS 7

su - root
yum install -y squid httpd-tools
[root@ct-squid ~]# rpm -q squid
squid-3.5.20-12.el7.x86_64

設定參數檔

vi /etc/squid/squid.conf
:
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
:

第一次啟動與設定自動啟動

systemctl restart squid.service
systemctl enable squid.service
  • 要瞭解 Proxy 被存取狀況可以看 /var/log/squid/access.log 內容紀錄
  • 通常無法正常啟動可以依據 systemctl status squid.service 的顯示看到問題與解決方案

相關參考資料