|
|
|
三、代理服务器软件的安装
squid的安装
freebsd本身的ports程序带有squid的稳定版本。目前squid的最新版本是2.4.STABLE6。在freebsd的/usr/ports/www/squid 目录下执行make;make install就会将最新版本的squid代码下载、编译并最终安装到/usr中的相应路径中。
Squid本身会被安装到/usr/local/sbin下 Squid的cache目录默认为/usr/local/squid/cache Squid的log目录默认为/usr/local/squid/logs squid的配置文件目录默认为/usr/local/etc/squid
这样的安装方式比直接使用二进制的package安装要好。因为二进制的package不能保证在自定义的系统上稳定运行。下载源代码代码在本地进行编译之前,首先会校验源代码的MD5 checksum,这样能保证我得到的源代码是未经修改过的版本。然后再在本地进行编译。最后安装到相应目录。
Squid的配置
Squid的配置文件是squid.conf
部分参数的配置如下:(为保证代理服务器安全,部分参数用*代替)
http_port 8080 设置http代理端口为8080 cache_peer pa.us.ircache.net sibling 3128 3130 login=*:* cache_peer sj.us.ircache.net sibling 3128 3130 login=*:* cache_peer * parent 13280 4827 htcp *:*
这几行是使用squid可以和其他几台机器进行协同工作的特性,同几台组成cache_peer。具体设置在后面的优化部分会解释。
cache_peer_domain * .edu.cn设置.edu.cn的域名使用某个cache_peer访问 cache_mem 400 MB设定内存cache的大小为400M cache_swap_low 80 cache_swap_high 97这两行是设置cache进行替换的闸值。当占用到97%的cache后,cache中的内容将被清空20%。 maximum_object_size 20000 KB 最大对象大小为20M. maximum_object_size_in_memory 10000 KB 内存中最大的对象大小为10M ipcache_size 4096 ip对应cache的大小为4096 fqdncache_size 4096 域名全称cache的大小为4096 cache_replacement_policy heap LFUDA cache替换策略 memory_replacement_policy heap LRU 内存替换策略 cache_dir ufs /usr/local/squid/cache 25000 16 256 cache存放的路径大小及具体配置 dns_nameservers * * * * * 内部指定dns服务器 authenticate_program * * 身份认证程序 authenticate_children 32 身份认证程序启动的进程数目 request_body_max_size 5 MB 最大请求的body大小 reply_body_max_size 20 MB 最大回应的body大小 acl all src 0.0.0.0/0.0.0.0 acl dorm proxy_auth 192.168.0.0/255.255.0.0 REQUIRED acl bjpu proxy_auth 202.112.64.0/255.255.240.0 REQUIRED acl bjpu2 proxy_auth 211.71.80.0/255.255.240.0 REQUIRED
访问控制列表
acl banned_sites {过滤的关键字} http_access deny banned_sites deny_info ERR_BANNED_SITE banned_sites
禁止访问违禁站点的设置
acl manager proto cache_object acl localhost src 127.0.0.1/255.255.255.255 acl SSL_ports port 443 563 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 563 # https, snews 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
设置可以连接的端口
http_access allow dorm http_access allow bjpu http_access allow bjpu2 http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access deny all
允许http访问
icp_access allow *允许cache_peer使用ICP协议访问 proxy_auth_realm BJPU proxy-caching web server 验证框提示的banner cache_mgr liukange@netease.com cache管理员的电子邮件地址 cache_effective_user * cache_effective_group * 执行cache程序的用户uid和gid visible_hostname cnproxy.bjpu.edu.cn cache服务的机器名 memory_pools on 内存池设置为打开。 memory_pools_limit 50 MB 内存池的大小
|
|
|
|
|
|
|
|
|
|
|