[email protected] squid]# cat squid.conf
#
# Recommended minimum configuration:
#
visible_hostname www.jd.com #设置代理服务器名称
cache_mgr [email protected] #设置缓存管理员邮箱
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl vlan1 src 192.168.1.0/24 #定义一个网段
acl baidu dstdomain .baidu.com #定义一个域名,www可以不写 。一定要写
acl test url_regex ^http://www.rhce.cc/test/.*\.txt # 定义一个网站的txt文件
acl txt urlpath_regex \.txt& #定义所有网站的txt文件
acl zhangsan src 192.168.1.4/32 #定义一个ip
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow vlan1 #允许vlan1上网 备注:此处分优先级
cache deny txt #所有的网站的txt文件不做缓存
http_access deny baidu
http_access deny zhangsan #禁止zhangsan使用代理服务器
http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access deny all
# Squid normally listens to port 3128
http_port 8889 #设置代理服务器端口为8889
# Uncomment and adjust the following to add a disk cache directory.
cache_swap_low 90 #设置硬盘的缓存最低为90%
cache_swap_high 95 #设置硬盘的缓存所占硬盘空间的95%,超过95%,删除5%老数据,回到硬盘空间90%
cache_mem 10 MB #设置内存中的缓存
cache_dir ufs /var/spool/squid 100 16 256
#缓存存放位置100代表100M,16代表16个目录,每个目录里面还有256子目录,请尽量启用此功能
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
# Add any of your own refresh_pattern entries above these.
#设置缓存时间,最小为1440分钟,最大为10080分钟,超过10080认为老数据
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