免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2572 | 回复: 0
打印 上一主题 下一主题

Freebsd 7.0 下用squid做本地Web加速代理 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-22 06:50 |只看该作者 |倒序浏览

Freebsd 7.0 下用squid做本地Web加速代理

Freebsd 7.0 下用squid做本地Web加速代理

实例环境:
服务器配置:Intel(R) Xeon(TM) CPU 2.80GHz +1G MEM+SCSI 73G
操作系统:Freebs7.0 Realese
机器IP地址:192.168.0.14
本地Web服务器端口为8080
1.先升级ports
#cd /usr/share/examples/cvsup
#cvsup -g -L 2 ports-supfile
2.装最新squid2.6
#cd /usr/ports/www/squid/
#make install clean
#rehash
3.编辑squid.conf文件
为了省时间,删除原配置文件后重新建立一个
以下是本人配置文件关键部分
-----------------------------------------------------------------------------------------
http_port 192.168.0.14:80 vhost vport
hierarchy_stoplist cgi-bin ?
hierarchy_stoplist -i ^https:\\ ?
acl QUERY urlpath_regex -i cgi-bin \?
acl denyssl urlpath_regex -i ^https:\\
no_cache deny QUERY
no_cache deny denyssl
cache_mem  384 MB
cache_swap_low 85
cache_swap_high 95
maximum_object_size  40 MB
maximum_object_size_in_memory 8192 KB
ipcache_size 4096
ipcache_low 90
ipcache_high 95
fqdncache_size 4096
cache_dir ufs /cache1 5120 16 256
cache_dir ufs /cache2 5120 16 256
cache_access_log /usr/local/squid/var/logs/access.log
cache_log /usr/local/squid/var/logs/cache.log
cache_store_log /usr/local/squid/var/logs/store.log
pid_filename /usr/local/squid/var/logs/squid.pid
acl OverConnLimit maxconn 10
http_access deny OverConnLimit
acl all src 0.0.0.0/0.0.0.0
acl myip dst 192.168.0.14
acl Localhost src 127.0.0.1 192.168.0.14
acl Manager proto cache_object
acl Safe_ports port 80
http_access deny !myip
http_access allow Manager Localhost
http_access deny Manager
http_access deny !Safe_ports
http_access allow all
visible_hostname cache.askwan.com
cache_mgr askwan@askwan.com
visible_hostname Askwan-Squid-Cache-Server
cache_effective_user squid
cache_effective_group squid
icp_port 0
cache_peer 192.168.0.14 parent 8080 0 no-query originserver
保存退出
创建squid文件系统和日志目录
#mkdir /cache1
#mkdir /cache2
#mkdir /usr/local/squid/var/logs/
#chown –R squid:squid  /cache1
#chown –R squid:squid  /cache2
#chown –R squid:squid  /usr/local/squid/var/log
4.启动调试
#squid –z
前台调试
#squid -NCd1
2008/06/11 18:35:52| Starting Squid Cache version 2.6.STABLE20 for i386-portbld-freebsd7.0...
2008/06/11 18:35:52| Process ID 72219
2008/06/11 18:35:52| With 11072 file deors available
2008/06/11 18:35:52| Using kqueue for the IO loop
2008/06/11 18:35:52| Performing DNS Tests...
2008/06/11 18:35:52| Successful DNS name lookup tests...
2008/06/11 18:35:52| DNS Socket created at 0.0.0.0, port 61699, FD 6
2008/06/11 18:35:52| Adding domain com from /etc/resolv.conf
2008/06/11 18:35:52| Adding nameserver 202.96.209.133 from /etc/resolv.conf
2008/06/11 18:35:52| User-Agent logging is disabled.
2008/06/11 18:35:52| Referer logging is disabled.
2008/06/11 18:35:52| Unlinkd pipe opened on FD 11
2008/06/11 18:35:52| Swap maxSize 10485760 KB, estimated 806596 objects
2008/06/11 18:35:52| Target number of buckets: 40329
2008/06/11 18:35:52| Using 65536 Store buckets
2008/06/11 18:35:52| Max Mem  size: 393216 KB
2008/06/11 18:35:52| Max Swap size: 10485760 KB
2008/06/11 18:35:52| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
2008/06/11 18:35:52| Rebuilding storage in /cache1 (CLEAN)
2008/06/11 18:35:52| Rebuilding storage in /cache2 (CLEAN)
2008/06/11 18:35:52| Using Least Load store dir selection
2008/06/11 18:35:52| Current Directory is /usr/ports/www/squid
2008/06/11 18:35:52| Loaded Icons.
2008/06/11 18:35:53| Accepting accelerated HTTP connections at 192.168.0.14, port 80, FD 15.
2008/06/11 18:35:53| Accepting SNMP messages on port 3401, FD 16.
2008/06/11 18:35:53| WCCP Disabled.
2008/06/11 18:35:53| Pinger socket opened on FD 18
2008/06/11 18:35:53| Configuring Parent 192.168.0.14/8080/0
2008/06/11 18:35:53| Ready to serve requests.
2008/06/11 18:35:53| Done reading /cache1 swaplog (1 entries)
2008/06/11 18:35:53| Done reading /cache2 swaplog (1 entries)
2008/06/11 18:35:53| Finished rebuilding storage from disk.
2008/06/11 18:35:53|         2 Entries scanned
2008/06/11 18:35:53|         0 Invalid entries.
2008/06/11 18:35:53|         0 With invalid flags.
2008/06/11 18:35:53|         2 Objects loaded.
2008/06/11 18:35:53|         0 Objects expired.
2008/06/11 18:35:53|         0 Objects cancelled.
2008/06/11 18:35:53|         0 Duplicate URLs purged.
2008/06/11 18:35:53|         0 Swapfile clashes avoided.
2008/06/11 18:35:53|   Took 0.8 seconds (   2.4 objects/sec).
2008/06/11 18:35:53| Beginning Validation Procedure
2008/06/11 18:35:53|   Completed Validation Procedure
2008/06/11 18:35:53|   Validated 2 Entries
2008/06/11 18:35:53|   store_swap_size = 4k
2008/06/11 18:35:53| storeLateRelease: released 0 objects
出现Ready to serve requests.  表示启动正常了  ctrl+c中止
后台启动用
#squid –s
其他一些常用指令
squid.conf 排错。
#squid -k parse  
停止 squid
#squid -k shutdown
重载入修改过的squid.conf
#squid -k reconfigure
Squid开机自动启动
/etc/rc.conf
添加如下行:  
squid_enable = “YES”
还有很多指令可以参考文档
剩下的就是需要根据各业务需要做参数的修改和优化
那么实际本机数据走向为


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/74/showart_1906328.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP