
编译安装:
tar zxvf squid-2.5.STABLE9.tar.gz
cd squid-2.5.STABLE9
./configure --prefix=/usr/local/squid \
--enable-arp-acl \
--enable-linux-netfilter \
--enable-pthreads \
--enable-err-language="Simplify_Chinese" \
--enable-default-err-language="Simplify_Chinese" \
--enable-auth="basic" \
--enable-baisc-auth-helpers="NCSA" \
--enable-underscore
/usr/local/squid/sbin/squid -z #建立squid缓存目录
/usr/local/squid/var/cache、/usr/local/squid/var/logs两个目录的属主改为nobody,或者权限设为0777,否则squid不能启动
设置squid支持用户认证:
说明:透明代理和用户认证功能不能同时应用。否则用户认证功能不起作用。
假定squid source目录在/squid-2.5.STABLE9
2. # cd /squid-2.5.STABLE9/helpers/basic_auth/NCSA/
# make ncsa_auth
3. 拷贝生成的执行文件ncsa_auth到squid执行文件目录
# cp ncsa_auth /usr/local/squid/bin
用户认证配置如下:
auth_param basic program /usr/local/squid/bin/ncsa_auth /usr/local/squid/etc/password
auth_param basic children 10
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 20 hours
acl normal proxy_auth REQUIRED
http_access allow normal
auth_param basic casesensitive off
注意事项:
acl normal proxy_auth REQUIRED语句定义的normal不需要用acl normal src
xxx.xxx.xxx.xxx重新定义,系统会默认源IP为0.0.0.0/0,如果normal用acl语句重新定义了,squid启动会报如下错
误:aclParseAclLine: ACL 'normal' already exists with different type,
skipping.
squid.conf中默认的http_access deny all必须注释,否则用户认证不能成功
某些配置讲解:
cache dir ufs /home/squid/cache 1024 16 256
---- #硬盘缓冲区的大小,大小为1GB,一级目录16个,二级目录256个。
---- cache access log /var/log/squid/access.log
---- #该log文件是用来描述每次客户请求HTTP内容时高速缓存命中或未命中的项目,同时还描述提出请求的主机身份及它们所需要的内容,它是用SQMGRLOG等软件分析记费的基础。
---- cache log /var/log/squid/cache.log
---- #用于描述当Squid守护进程启动时可以看到的内存容量、交换空间的大小、高速缓存目录的位置、所接受的连接类型以及接受连接的端口。
---- cache_store_log /var/log/squid/store.log
---- #用于描述页面从高速缓存中被调入调出的情况。
pid filename /var/run/squid.pid
#Squid进程的进程号。
dns nameservers 192.x.x.1
#定义域名解析服务器的地址。
cache_mgr squidadmin@your.domain
#cache管理员的邮件箱地址。
reference age 1 week
#设置缓冲区的更新周期。
maximum object size 4096 KB
#设置允许被缓存的一次性最大请求。
cache_effective_user squidadmin squidadmin
#以用户squidadmin的身份运行。
参考:http://www.moon-soft.com/download/info/2415.htm
http://www.cublog.cn/opera/showart.php?blogid=12869&id=66756
http://www1.stock1818.com/soft/Article.Asp?id=11763