1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 |
#http_port指令告诉squid在哪个端口侦听HTTP请求。默认端口是3128,除下面的形式外,也可以是http_port 192.168.63.50:3128
http_port 3128
icp_port 3130
#缓存目录的设置,可以设置多个缓存目录,语法为:<cache_dir> <aufs|ufs> <目录所在> <MBytes大小> <dir1> <dir2>
cache_dir ufs /var/spool/squid 1000 64 1024
#下面是关于日志文件的放置目录与文件名!
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
pid_filename /var/run/squid.pid
#关闭认证机制,有些版本的 squid 会自动的加入代理认证机制,而普通情况下是不需要的,故找到包括auth_param的行,给它们加上注释
#auth_param basic children 5
#auth_param basic realm Squid proxy-caching web server
#auth_param basic credentialsttl 2 hours
#设置squid用户及用户组、管理员账号
cache_effective_user squid
cache_effective_group squid
cache_mgr youraccount@your.e.mail
# 与内存有关的配置:因为我的系统内存很小,所以只给 8 MB!如果您的物理内存很大的情况下,例如 512 MB,可以考虑加大到 64 或 128 MB。
cache_mem 128 MB
# 与磁盘容量有关的配置(注:下列的 90 与 95 是百分比 ),如果您的 cache_dir 所在磁盘很大时,可以考虑将 4096 改成 32768 KB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 4096 KB
# 与内存保存资料有关的配置
maximum_object_size_in_memory 8 KB
#定义acl(访问控制列表), 语法为:acl<acl> <acl名称> <acl类型> <配置的内容>
#黑体为用户自定义部分
acl All src 0/0
acl Manager proto cache_object
acl Localhost src 127.0.0.1/32
acl Safe_ports port 80 21 443 563 70 210 280 488 591 777 1025-65535
acl SSL_ports 443 563
acl CONNECT method CONNECT
acl MyNetwork src 192.168.0.0/16
#利用前面定义的acl,定义访问控制规则
http_access allow Manager Localhost
http_access deny Manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow MyNetwork
http_access deny All
#定义与其它代理服务器的关系,语法: <cache_peer> <主机名称> <类别> <http_port> <icp_port> <其它参数>
cache_peer 192.168.60.6 parent 4480 7 no-query default
#设置与其它代理服务器的关系:
# <cache_peer_access> <上层 Proxy > <allow|deny> <acl名称>
#cache_peer_access 192.168.60.6 allow aclxxx
#cache_peer_access 192.168.60.6 deny !aclxxx
coredump_dir /var/spool/squid |