基于反向代理的Web缓存加速现代理服务器

2009-05-13 01:06:40来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


基于Apachemod_proxy的反向代理缓存加速实现
Apache包含了mod_proxy模块,可以用来实现代理服务器,针对后台服务器的反向加速
安装apache1.3.x编译时:
--enable-shared=max--enable-module=most
注:Apache2.x中mod_proxy已经被分离成mod_proxy和mod_cache:同时mod_cache有基于文件和基于内存的不同实现
创建/var/www/proxy,设置apache服务所用户可写
mod_proxy配置样例:反相代理缓存+缓存
架设前台的www.example.com反向代理后台的www.backend.com的8080端口服务。
修改:httpd.conf
<VirtualHost*>
ServerNamewww.example.com
ServerAdminadmin@example.com
#reverseproxysetting
ProxyPass/http://www.backend.com:8080/
ProxyPassReverse/http://www.backend.com:8080/
#cachedirroot
CacheRoot"/var/www/proxy"
#maxcachestorage
CacheSize50000000
#hour:every4hour
CacheGcInterval4
#maxpageexpiretime:hour
CacheMaxExpire240
#Expiretime=(now-last_modified)*CacheLastModifiedFactor
CacheLastModifiedFactor0.1
#defaltexpiretag:hour
CacheDefaultExpire1
#forcecompleteafterprecentofcontentretrived:60-90%
CacheForceCompletion80
CustomLog/usr/local/apache/logs/dev_access_logcombined
</VirtualHost>

基于Squid的反向代理加速实现
Squid是一个更专用的代理服务器,性能和效率会比Apache的mod_proxy高很多。
如果需要combined格式日志补丁:
http://www.squid-cache.org/mail-archive/squid-dev/200301/0164.html
squid的编译:
./configure--enable-useragent-log --enable-referer-log--enable-default-err-language=Simplify_Chinese--enable-err-languages="Simplify_ChineseEnglish"--disable-internal-dns 
make
#makeinstall
#cd/usr/local/squid
makedircache
chownsquid.squid*
vi/usr/local/squid/etc/squid.conf
在/etc/hosts中:加入内部的DNS解析,比如:
192.168.0.4[url]www.chedong.com[/url]
192.168.0.4news.chedong.com
192.168.0.3bbs.chedong.com
---------------------cuthere----------------------------------
#visiblename
visible_hostnamecache.example.com
#cacheconfig:spaceuse1Gandmemoryuse256M
cache_dirufs/usr/local/squid/cache102416256
cache_mem256MB
cache_effective_usersquid
cache_effective_groupsquid

http_port80
httpd_accel_hostvirtual
httpd_accel_single_hostoff
httpd_accel_port80
httpd_accel_uses_host_headeron
httpd_accel_with_proxyon
#acceleratermydomainonly
aclacceleratedHostAdstdomain.example1.com
aclacceleratedHostBdstdomain.example2.com
aclacceleratedHostCdstdomain.example3.com
#acceleraterhttpprotocolonport80
aclacceleratedProtocolprotocolHTTP
aclacceleratedPortport80
#accessarc
aclallsrc0.0.0.0/0.0.0.0
#AllowrequestswhentheyaretotheacceleratedmachineANDtothe
#rightportwithrightprotocol
http_accessallowacceleratedProtocolacceleratedPortacceleratedHostA
http_accessallowacceleratedProtocolacceleratedPortacceleratedHostB
http_accessallowacceleratedProtocolacceleratedPortacceleratedHostC
#logging
emulate_httpd_logon
cache_store_lognone
#manager
aclmanagerprotocache_object
http_accessallowmanagerall
cachemgr_passwdpassall

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:从HTTP服务器状态代码分析

下一篇:在ApacheHTTPD服务器中使用DSO完全分析