檢查是否已經安裝Squid
rpm -qa | grep squid
設定啟動Squid
chkconfig --level 345 squid on | off
手動開啟 | 關閉
/etc/init.d/squid start | stop | restart
設定檔位置
/etc/squid.conf
參數設定
設定埠號
http_port 3128
設定管理者郵件地址
cache_mgr root
設定可用來源地址
acl test src 192.168.0.0/255.255.255.0
http_access allow test
設定不可用的來源地址
acl testgroup src 192.168.1.0/255.255.255.0
http_access deny testgroup
拒絕包含特定字元的連線(針對超連結)
acl url_deny url_regex "/etc/squid/url.acl"
http_access deny url_deny
新增 /etc/squid/url.acl
/sex/.*
管制連線時間
acl restricted_weekdays time MTWHF 8:30-18:00
# S : Sunday M : Monday T : Tuesday W : Wednesday
# H : Thursday F : Friday A : Saturday
acl test src 192.168.0.0/255.255.255.0
http_access allow test restricted_weekdays
設定暫存檔大小
cache_dir ufs /var/cache/squid 100 16 256
# ufs : 種類,不用變更
# /var/cache/squid : 暫存檔存放的目錄
# 100 : 以 M 為單位,也就是總量為100M
# 16 : 第一層的子目錄數量
# 256 : 第二層的子目錄數量
設定暫存物件的大小
maximum_object_size 8192KB
# 最大物件大小
mimimum_object_size 100KB
# 最小物件大小