返回   青蛙论坛 » IT论坛 » 操作系统类
用户名
密码
帮助 会员 日历 标记论坛为已读

回复
 
主题工具 显示模式
旧 11-19-2006, 22:29   #1
chyangwa
蝌蚪-小毛驴
 
chyangwa的头像
 
注册日期: Nov 2000
来自: 上海
帖子: 8,285
精华: 6
squid 2.6

Squid 2.6.PRE2 release

http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.PRE2-RELEASENOTES.html

http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.PRE2.tar.gz
http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.PRE2.tar.bz2

$Id: release-2.6.html,v 1.11 2006/06/06 08:20:55 hno Exp $
squid-2.6.PRE1 May 29 2006
squid-2.6.PRE2 Jun 6 2006

新特性:(就是把证明好用的patch整合进来了)
Collapsed forwarding
Support for epoll under Linux
Support for Etag and Vary HTTP headers
Logging enhancements
Authentication enhancements
TPROXY totally transparent proxy support under Linux

配置上的改动;
http_port 配置 transparent or vhost ...
accelerated

httpd_accel_* 都被替换掉了
透明代理被 http_port 80 transparent
httpd_accel_uses_host_header 被 http_port 80 vhost 替换掉
httpd_accel_host httpd_accel_port 被 cache_peer 替换掉

cache_access_log 改成 access_log 了

no_cache deny QUERY
改成
cache deny QUERY

logformat
access_log [ [acl acl ...]]

# check_hostnames on

# allow_underscore on

# read_ahead_gap 16 KB

# collapsed_forwarding off

# refresh_stale_hit 0 seconds

# follow_x_forwarded_for deny all
# acl_uses_indirect_client on

# log_uses_indirect_client on

# TAG: log_access allow|deny acl acl...

# error_map http://your.server/error/404.shtml 404

# via on

# TAG: linux_tproxy on|off

# iptables -t tproxy -A PREROUTING -m tcp --dport 80 \
# -j TPROXY --on-port 90
chyangwa离线中   回复时引用此帖
旧 11-19-2006, 22:29   #2
chyangwa
蝌蚪-小毛驴
 
chyangwa的头像
 
注册日期: Nov 2000
来自: 上海
帖子: 8,285
精华: 6
回复: squid 2.6

http_port 80 改为
http_port 80 vhost

cache_access_log ... 改为
access_log ...

no_cache ...改为
cache ...

httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_single_host off
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
删除
改为(根据具体情况定义acl 设置转发)
acl ipcndm dstdomain .ipcn.org
cache_peer www.ipcn.org parent 80 0 originserver
cache_peer_access www.ipcn.org allow ipcndm
cache_peer_access www.ipcn.org deny all

always_direct allow !ipcndm
never_direct allow ipcndm

其他还有很多
比如:不记图片类访问日志
acl nolog urlpath_regex \.gif \.jpg \.css \.js \.swf
access_log /data/squid/var/logs/access.log common !nolog

squid.conf 配置官方参数相关改动说明:
1. http_port加参数
a) http_port 80 vhost
2. cache_peer hostname type http_port icp_port [options]
a) originserver
b) sourcehash
c) name=xxx 加速同一机器时不同端口时定位用
3. no_cache 改为 cache
a) cache deny QUERY
4. cache_vary on
a) Set to off to disable caching of Vary:in objects.
5. broken_vary_encoding 不要相信 ETag 因为有gzip
a) acl apache rep_header Server ^Apache
b) broken_vary_encoding allow apache
6. logformat
a)
b)
c)
d) 下面是squid默认提供的
e) #logformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
f) #logformat squidmime %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A \
%mt [%>h] [%<h]
g) #logformat common %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st %Ss:%Sh
h) #logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st \
"%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh
7. access_log
a) cache_access_log改为access_log
b) access_log <filepath> [<logformat name> [acl acl ...]]
8. check_hostnames on
9. allow_underscore on
10. refresh_pattern 增加
a) ignore-no-cache
b) ignore-private
c) ignore-auth
11. collapsed_forwarding off
12. refresh_stale_hit 0 seconds
13. follow_x_forwarded_for deny all
14. acl_uses_indirect_client on
15. log_uses_indirect_client on
16. log_access allow|deny acl acl...
17. httpd_suppress_version_string off
18. httpd_accel_host删除
19. httpd_accel_port删除
20. httpd_accel_single_host删除
21. httpd_accel_with_proxy删除
22. httpd_accel_uses_host_header删除
23. error_map http://your.server/error/404.shtml 404
24. via on
chyangwa离线中   回复时引用此帖
旧 11-19-2006, 22:37   #3
chyangwa
蝌蚪-小毛驴
 
chyangwa的头像
 
注册日期: Nov 2000
来自: 上海
帖子: 8,285
精华: 6
回复: squid 2.6

squid-2.6之Web反向代理加速实做/防盗链/防盗用/防爬虫

--------------------------------------------------------------------------------

http://www.chinaunix.net 作者:HonestQiao 发表于:2006-09-28 09:57:22
【发表评论】【查看原文】【Proxy服务器讨论区】【关闭】

[操作实例] squid-2.6.STABLE1-20060726之Web加速实做


  2.6相对2.5有了一些改变,大家可以去看:http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE1-20060726-RELEASENOTES.html#s2

  1. 下载squid2.6 http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE1-20060726.tar.gz

  2. 安装:

wwwtest137#tar xzvf squid-2.6.STABLE1-20060726.tar.gz
wwwtest137#cd squid-2.6.STABLE1-20060726
wwwtest137#configure --prefix=/usr/local/squid --enable-dlmalloc --with-pthreads --enable-poll --disable-internal-dns --enable-stacktrace --enable-removal-policies="heap,lru" --enable-delay-pools --enable-storeio="aufs,coss,diskd,ufs"
wwwtest137#make
wwwtest137#make install


  安装完成了。
  因为是测试的,所以相关的参数可能并不是比较完善的,但是使用是没有问题的。

  3. 配置:以下是部分关键配置,其他与2.5的相同

#squid.conf
#服务器IP 192.168.1.1
#监听服务器的80端口,透明代理,支持域名和IP的虚拟主机
http_port 192.168.1.1:80 transparent vhost vport

#限制同一IP客户端的最大连接数
acl OverConnLimit maxconn 16
http_access deny OverConnLimit

#防止天涯盗链,转嫁给百度
acl tianya referer_regex -i tianya
http_access deny tianya
deny_info http://www.baidu.com/logs.gif tianya

#防止被人利用为HTTP代理,设置允许访问的IP地址
acl myip dst 192.168.1.1
http_access deny !myip

#防止百度机器人爬死服务器
acl AntiBaidu req_header User-Agent Baiduspider
http_access deny AntiBaidu

#允许本地管理
acl Manager proto cache_object
acl Localhost src 127.0.0.1 192.168.1.1
http_access allow Manager Localhost
http_access deny Manager

#仅仅允许80端口的代理
acl Safe_ports port 80 # http
http_access deny !Safe_ports
http_access allow all

#Squid信息设置
visible_hostname www.test137.com
cache_mgr webmaster@test137.com

#基本设置
cache_effective_user squid
cache_effective_group squid
tcp_recv_bufsize 65535 bytes

#2.5的反向代理加速配置
#httpd_accel_host 127.0.0.1
#httpd_accel_port 80
#httpd_accel_single_host on
#httpd_accel_uses_host_header on
#httpd_accel_with_proxy on
#2.6的反向代理加速配置
#代理到本机的80端口的服务,仅仅做为原始内容服务器
cache_peer 127.0.0.1 parent 80 0 no-query originserver

#错误文档
error_directory /usr/local/squid/share/errors/Simplify_Chinese

#单台使用,不使用该功能
icp_port 0





  4. http服务器配合设置:
http服务器,监听到127.0.0.1的80端口。

  5. 数据走向:
访问者=>192.168.1.1:80=>127.0.0.1:80

  6. 测试:
/usr/local/squid/sbin/squid -z
/usr/local/squid/sbin/squid -NCd1
  好了,现在访问你的服务器看看,已经好了。

  为了测试是否可用,把http服务器给停了,你就可以看到squid2.6的信息了。

  另外,我们设置:
SQUID监听外部IP的80端口
HTTP服务器监听本机127.0.0.1的80端口
这样子不用任何防火墙参与,即可完成web反向代理加速。
chyangwa离线中   回复时引用此帖
旧 11-25-2006, 19:24   #4
chyangwa
蝌蚪-小毛驴
 
chyangwa的头像
 
注册日期: Nov 2000
来自: 上海
帖子: 8,285
精华: 6
回复: squid 2.6

squid禁止多线程并发下载的简单方法
October 15, 2006 on 10:58 pm | In Web, Other | Tag linux, squid | No Comments
最近发现多线程并发下载,把squid冲击的一塌糊涂。Squid目前对Range Request的处理,确实不如人意。所以无奈只好想办法,禁止所有带Range请求的下载。

实际方法还是比较简单的, squid 2.5以后,可以通过匹配request header来定义ACL,然后拒绝掉这类访问就可以了.
acl rangeget req_header Range .*
http_access deny rangeget
注意这个http_access要写在比较靠前的位置比较好.
chyangwa离线中   回复时引用此帖
旧 11-25-2006, 19:25   #5
chyangwa
蝌蚪-小毛驴
 
chyangwa的头像
 
注册日期: Nov 2000
来自: 上海
帖子: 8,285
精华: 6
回复: squid 2.6

squid纯内存缓存
November 20, 2006 on 9:16 pm | In Linux, Web | Tag linux, squid | No Comments
看见网上不少介绍squid的使用经验,说可以用ramdisk/tmpfs内存文件系统来加速squid. 个人认为完全没有必要,直接简单配置一下,就可以让Squid直接充分利用大内存:
maximum_object_size 32768 KB
cache_mem 1512 MB # Cache使用的最大内存
maximum_object_size_in_memory 128 KB # Cache在memory中最大Object的大小
memory_pools_limit 1500 MB # 小对象内存池的大小
cache_dir null /tmp # 使用null disk
一些需要注意的事项: squid在编译的时候,要支持nullfs. maximum_object_size_in_memory应该尽量大于最大的object的尺寸,但是也不要太大,否则会影响内存分配的效率.

考虑一下实际应用的情况: 平均页面对象都不是很大,对象个数也不是很多,同时又有充足的内存余量,内容跟新还算频繁,这个时候,1.5G和20G或者40G的cache的请求命中率其实相差非常细微,不过是99%和99.9%的区别,这个时候,完全有理由,抛下缓慢的disk cache,直接使用memory cache,这样不但能有效降低系统load,还能使squid自身更加轻快便捷.
chyangwa离线中   回复时引用此帖
回复


主题工具
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭
论坛跳转



所有的时间均为北京时间。 现在的时间是 07:07.


NewvBB Core 1.1 Final - vBulletin v3.0.3
中文化与插件制作 NewVBB.com™ 2024。
友情连接        
摩托车.上海.中国        
         
         
         
         
         

上海市通信管理局
沪ICP备010502
沪ICP备05000578号