squid代理服务器安装配置

注:SQUID代理服务器工作在第七层,比较耗费系统资源,缺省情况下squid防止所有人访问!

#./configure –with-pthreads –enable-ssl –enable-linux-netfilter –enable-auth –enable-storeio=ufs,aufs,diskd,coss
#make ; make install
#groupadd squid
#useradd –g squid squid

Vi /usr/local/squid/etc/squid.conf

http_port 3128
cache_dir ufs /webcache 4000 64 128
cache_access_log none
cache_log /dev/null
cache_store_log none
acl share src 192.168.0.0/255.255.255.0
http_access allow share
httpd_accel_port 80
httpd_accel_host virtual
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
error_directory /usr/share/squid/errors/Simplify_Chinese
dns_nameservers    61.137.94.195 202.103.96.112 220.168.121.68
cache_mgr zjjboy@vip.sina.com
maximum_object_size 4096 KB
#下面几个就是说遇到URL中有包含cgi-bin和以https:\\开头的都不要缓存,
#还有asp、cgi、php等动态脚本也不要缓存,
#因为这些脚本通常都是动态更新的,这样数据不同步。
#还有https://开通的不缓存是因为一般我们进行电子商务交易,
#例如银行付款等都是采用这个的,如果把信用卡号什么缓存那不是很危险。
hierarchy_stoplist cgi-bin ?
hierarchy_stoplist -i ^https:\\ ?
acl QUERY urlpath_regex -i cgi-bin \? \.asp \.php \.jsp \.cgi
acl denyssl urlpath_regex -i ^https:\\
no_cache deny QUERY
no_cache deny denyssl
acl sex url_regex -i sex
acl photo urlpath_regex -i \.gif$ \.jpg$
http_access deny photo
http_access deny sex
http_access allow all




在squid.conf里有两行这种配置
cache_swap_low 80
cache_swap_high 95
意思就是说,当cache高于95%的时候开始删除cache,直到保持80%的cache容量.

配置文件中有memory_pools选项
用法 memory_pools on|off
默认 memory_pools on
相关的有memory_pools_limit 8M
在服务器只提供proxy服务而没有像apache那样的其它服务时,可以关闭memory_pools 选项,让squid自动决定分配多少内存:
memory_pools off
memory_pools_limit none
如果不是专门的服务器,就要打开memory_pools 选项,适当的设置
memory_pools on
memory_pools_limit 1024M   

SQUID常见错误
错误01>;
    squid -z无法执行
现象01>;
    在安装squid软件之后,执行squid -z,出现如下信息FF1A
    [root@abc sbin]# ./squid -z
    2004/12/19 12:49:25| Creating Swap Directories
    FATAL: Failed to make swap directory /usr/local/squid/var/cache/00: (13) Permission denied
    Squid Cache (Version 3.0-PRE3): Terminated abnormally.
    CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
    Maximum Resident Size: 0 KB
    Page faults with physical i/o: 6
解法01>;
    在squid.conf文件中,找到cache_dir参数所对应的目录(通常是/var/spool/squid),并找到cache_effective_user/cache_effective_group连个参数对应的用户:组,确认这个目录的所有者:属组是这两个参数,并且有完全访问的权限(7xx)。修改过后,就会成功执行这个命令。
BTW:其实,红字部分已经说明了问题的所在。
原理01>;
    无论用那个用户执行squid -z(通常都是用root安装,然后用root执行)命令,squid首先检查cache_dir对应的目录是否归属于cache_effective_user:cache_effective_group,并且有7xx的权限,然后再创建子目录。并且squid执行的时候,是以cache_effective_user用户来执行squid进程的,也要求对该目录有7xx的权限。通常的建议是,将这个目录的属主修改为cache_effective_user:cache_effective_group,而不是root:root。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值