PDA

查看完全版本 : squid 2.6


chyangwa
11-19-2006, 22:29
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
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
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反向代理加速。