??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久久久综合网天天,成人精品一区二区久久久,国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲高清不卡 国产成人精品久久亚洲 http://www.shnenglu.com/larryliuqing/category/18446.html׃n今天Code Sky, 共创明天Code Sky!zh-cnTue, 03 Jan 2012 04:22:20 GMTTue, 03 Jan 2012 04:22:20 GMT60【{】squid?/title><link>http://www.shnenglu.com/larryliuqing/archive/2012/01/03/163474.html</link><dc:creator>刘远?/dc:creator><author>刘远?/author><pubDate>Tue, 03 Jan 2012 03:54:00 GMT</pubDate><guid>http://www.shnenglu.com/larryliuqing/archive/2012/01/03/163474.html</guid><wfw:comment>http://www.shnenglu.com/larryliuqing/comments/163474.html</wfw:comment><comments>http://www.shnenglu.com/larryliuqing/archive/2012/01/03/163474.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/larryliuqing/comments/commentRss/163474.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/larryliuqing/services/trackbacks/163474.html</trackback:ping><description><![CDATA[<div style="color: #333333; font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 16px; line-height: 18px; font-weight: bold; height: 48px; padding-left: 30px; padding-top: 10px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; border-image: initial; overflow-x: hidden; overflow-y: hidden; text-align: -webkit-left; ">squid?/div><div style="color: #999999; font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; line-height: 18px; margin-top: 5px; margin-right: 0px; margin-bottom: 8px; margin-left: 0px; text-align: -webkit-left; ">2008q?2?1?星期?14:16</div><table style="table-layout: fixed; font-family: Arial; width: 958px; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: 18px; color: #333333; "><div class="44kmiuk" id="blog_text" style="color: #666666; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 30px; background-image: url(http://imgsrc.baidu.com/css/pic/item/8334ad430aed590772f05d38.jpg); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; padding-bottom: 80px; overflow-x: hidden; overflow-y: hidden; position: relative !important; border-image: initial; background-position: 100% 100%; background-repeat: no-repeat no-repeat; "><p style="line-height: normal; "><a name="top" style="text-decoration: none; color: rgb(81, 191, 224); "></a><a style="text-decoration: none; color: #4d4d4d; ">?/a><br /><a style="text-decoration: none; color: #4d4d4d; ">普通代?/a><br /><a style="text-decoration: none; color: #4d4d4d; ">透明代理</a><br /><a style="text-decoration: none; color: #4d4d4d; ">反向代理</a><br /><a style="text-decoration: none; color: #4d4d4d; ">故障处理</a><br /><a style="text-decoration: none; color: #4d4d4d; ">一个范?/a><br /><a style="text-decoration: none; color: #4d4d4d; ">一个限制访问的范例</a></p><p style="line-height: normal; ">官方|站Qhttp://www.squid-cache.org/</p><p style="line-height: normal; ">相关技术网站:(x)http://www.visolve.com/</p><h2><a name="intro" style="text-decoration: none; color: rgb(81, 191, 224); "></a>一. 代理服务?/h2><a style="text-decoration: none; color: #4d4d4d; line-height: normal; ">q回</a><h3>1. 什么是代理服务?Proxy Server)</h3><p style="line-height: normal; ">     代理服务可以代表其它计算Z递数据包或信?q些数据包和信息包括|页、电(sh)子邮件、多媒体文g和其它网l应用程序等。通过它的文g~存和访问控制等功能Q可以实现快速浏览和对用戯问的有效理?/p><p style="line-height: normal; ">     Web代理服务?通常所说的代理服务?是介于浏览器和W(xu)eb服务器之间的一台服务器,当你通过代理服务器上|浏览时Q浏览器不是直接到Web服务器去取回|页而是向代理服务器发出hQ由代理服务器来取回览器所需要的信息q传送给你的览器?而且Q大部分代理服务器都h~冲的功能,好象一个大的CacheQ它有很大的存储I间Q它不断新取得数据储存到它本机的存储器上,如果览器所h的数据在它本机的存储器上已经存在而且是最新的Q那么它?yu)׃重新从Web服务器取数据Q而直接将存储器上的数据传送给用户的浏览器Q这样就能显著提高浏览速度和效率?/p><p style="line-height: normal; "> 更重要的是:(x)代理服务器是 Internet链\U网x提供的一U重要的安全功能Q它的工作主要在开攄l互?(OSI) 模型的对话层。主要的功能有:(x)<br />   <br />  1、连接Internet与Intranet 充当firewallQ防火墙Q:(x)因ؓ(f)所有内部网的用户通过代理服务器访问外界时Q只映射Z个IP地址Q所以外界不能直接访问到内部|;同时可以讄 IP地址qo(h)Q限制内部网对外部的讉K权限Q另外,两个没有互联的内部网Q也可以通过W三方的代理服务器进行互联来交换信息?/p><p style="line-height: normal; ">  2、共享因特网q接Q节省IP开销Q如前面所Ԍ所有用户对外只占用一个IPQ所以不必租用过多的IP地址Q降低网l的l护成本。这P局域局内没有与外网相连的众多机器就可以通过内网的一C理服务器q接到外|,大大减少费用。当然也有它不利的一面,如许多网l黑客通过q种Ҏ(gu)隐藏自己的真实IP地址Q而逃过监视?/p><p style="line-height: normal; ">  3、提高访问速度Q节U通信带宽。而且通常代理服务器都讄一个较大的盘~冲区(可能高达几个GB或更大)Q当有外界的信息通过Ӟ同时也将其保存到~冲ZQ当其他用户再访问相同的信息Ӟ则直接由~冲Z取出信息Q传l用P从而达到提高访问速度的目的?/p><h3>2. 代理服务器的g需?/h3><p style="line-height: normal; ">代理服务器对于硬件的要求相当的高Q因为我们架设代理服务器的目的就是希望能够加快网l的传输速度因此Q虽然代理服务器几乎在Q何的 Linux pȝ上面都能跑,但是代理服务器最好还是有较高的硬仉|:(x)</p><p style="line-height: normal; ">CPU _好;</p><p style="line-height: normal; ">RAM _大,q也是很重要的一个硬件参?/p><p style="line-height: normal; ">Hard Disk 最好能?SCSI 接口的,因ؓ(f)速度与稳定度都比较好Q如果不能的话,那么 IDE 接口的硬盘由于目前速度也越来越快,所以?IDE 也没有问题,但是最好是『多块硬盘』的架构Q例如我d需?30 GB 的硬盘空_(d)那么最好是 10 GB 的硬盘三块这L(fng)架构较佳?最好在架设代理服务器时Q将整体L的规划做好,q且让代理服务器L的服务单U一点,最好只负责代理服务</p><p style="line-height: normal; ">每颗盘的容量不需要太大,此外Q最好将盘分割一下,一个分区在 2~4 GB 之间卛_Q因为分太大的话资料的搜寻耗费旉较长Q但是分区太又可能造成I间的浪?/p><p style="line-height: normal; ">cache 是放|在某个目录下的Q而最好一个目录底下就是独立的一个partition 。此外,׃ cache 所在的盘常常?x)有资料的存取,因此可能此一盘的损耗率?x)比较大Q所以这?cache 所在的盘最好不要跟重要数据文gQ例?/Q?/etcQ?/usrQ?/home {等重要的系l文件放在一P</p><p style="line-height: normal; ">也由?cache 所在的盘资料存取太密集了Q所以,盘的选择上面需?(1)转速不能太低; (2)头的机械臂需要可以忍受频J的动作Q?3)发热量不可太大,或者可以考虑加装盘用风扇?/p><p style="line-height: normal; ">|络卡与|络周边最好?GBytes 的网l卡</p><h3>3. 使用squid的好?/h3><p style="line-height: normal; ">squid是开源YӞ性能优秀。ƈ仍在世界各地的squid开发者的共同努力下,不断发展?/p><p style="line-height: normal; ">快速响应,减少|络d,Squid远EInternet对象保存为本地拷贝。当本地用户再次讉Kq些对象ӞSquid可以直接快速地提供对这些对象的讉KQ而不必再ơ占用带宽访问远E服务器上的对象?/p><p style="line-height: normal; ">增强讉K控制Q提高安全性。可以针对特定的的网站、用戗网l、数据类型实施访问控?/p><p style="line-height: normal; ">squid可以工作在普通代理模式、透明代理模式各反向代理模?/p><h3>4. squid的结?/h3><p style="line-height: normal; ">多个squid代理服务器可以通过icp协议怺沟通,形成?wi)Ş层次关系Q父代理、兄弟代理、子代理Q,构徏代理服务器群?/p><h2><a name="conf" style="text-decoration: none; color: rgb(81, 191, 224); "></a>? squid.conf的典型配|(普通代理)</h2><p style="line-height: normal; "><a style="text-decoration: none; color: #4d4d4d; ">q回</a></p><h3>1. 配置</h3><p style="line-height: normal; ">#vi /etc/squid/squid.conf</p><p style="line-height: normal; ">#http_port指o(h)告诉squid在哪个端口侦听HTTPh。默认端口是3128,除下面的形式?也可以是http_port 192.168.63.50:3128<br />http_port 3128<br />icp_port 3130</p><p style="line-height: normal; ">#~存目录的设|?可以讄多个~存目录,语法?<cache_dir> <aufs|ufs> <目录所?gt; <MBytes大小> <dir1> <dir2><br />cache_dir ufs /var/spool/squid 1000 64 1024</p><p style="line-height: normal; ">#下面是关于日志文件的攄目录与文件名Q?br />cache_access_log /var/log/squid/access.log<br />cache_log /var/log/squid/cache.log<br />cache_store_log /var/log/squid/store.log<br />pid_filename /var/run/squid.pid</p><p style="line-height: normal; ">#关闭认证机制Q有些版本的 squid ?x)自动的加入代理认证机制Q而普通情况下是不需要的,故找到包括auth_param的行Q给它们加上注释<br />#auth_param basic children 5<br />#auth_param basic realm Squid proxy-caching web server<br />#auth_param basic credentialsttl 2 hours</p><p style="line-height: normal; ">#讄squid用户?qing)用L(fng)、管理员账号<br />cache_effective_user squid<br />cache_effective_group squid <br />cache_mgr youraccount@your.e.mail</p><p style="line-height: normal; "># 与内存有关的配置Q因为我的系l内存很,所以只l?8 MBQ如果?zhn)的物理内存很大的情况下,例?512 MBQ可以考虑加大?64 ?128 MB?br />cache_mem 128 MB</p><p style="line-height: normal; "># 与磁盘容量有关的配置(注:(x)下列?90 ?95 是百分比 )Q如果?zhn)?cache_dir 所在磁盘很大时Q可以考虑?4096 Ҏ(gu) 32768 KB<br />cache_swap_low 90<br />cache_swap_high 95<br />maximum_object_size 4096 KB</p><p style="line-height: normal; "># 与内存保存资料有关的配置<br />maximum_object_size_in_memory 8 KB</p><p style="line-height: normal; ">#定义acl(讉K控制列表), 语法?acl<acl> <acl名称> <aclcd> <配置的内?gt;<br />#黑体为用戯定义部分</p><p style="line-height: normal; ">acl All src 0/0 <br />acl Manager proto cache_object <br />acl Localhost src 127.0.0.1/32 <br />acl Safe_ports port 80 21 443 563 70 210 280 488 591 777 1025-65535 <br />acl SSL_ports 443 563 <br />acl CONNECT method CONNECT <br /><strong>acl MyNetwork src 192.168.0.0/16</strong><br /><br />#利用前面定义的acl,定义讉K控制规则<br />http_access allow Manager Localhost<br />http_access deny Manager<br />http_access deny !Safe_ports<br />http_access deny CONNECT !SSL_ports<br /><strong>http_access allow MyNetwork</strong><br />http_access deny All</p><p style="line-height: normal; ">#定义与其它代理服务器的关p?语法: <cache_peer> <L名称> <cd> <http_port> <icp_port> <其它参数><br />cache_peer 192.168.60.6 parent 4480 7 no-query default</p><p style="line-height: normal; ">#讄与其它代理服务器的关p?<br /># <cache_peer_access> <上层 Proxy > <allow|deny> <acl名称><br />#cache_peer_access 192.168.60.6 allow aclxxx <br />#cache_peer_access 192.168.60.6 deny !aclxxx</p><p style="line-height: normal; ">coredump_dir /var/spool/squid</p><h3>2. Ȁzsquid</h3><p style="line-height: normal; ">1). 在开启squid之前Q你应该验证光|文件是否正。运行如下命令即可:(x)</p><p style="line-height: normal; "># squid -k parse</p><p style="line-height: normal; ">假如你看不到输出Q配|文件有效,你能l箋后面的步骤。然而,如果配置文g包含错误Qsquid?x)告诉你Q?/p><p style="line-height: normal; ">2). 初始化cache目录.卛_立缓存目录的存储格式</p><p style="line-height: normal; ">只需在第一ơ启动squid服务之前执行(在初ơ运行squid之前Q或者无Z时你增加了新的cache_dirQ你必须初始化cache目录?</p><p style="line-height: normal; "># squid -z</p><p style="line-height: normal; ">cache目录初始化可能花费一些时_(d)依赖于cache目录的大和数量Q以?qing)磁盘驱动器的速度。假如你惌察这个过E,请?X选项Q?/p><p style="line-height: normal; "># squid -zX</p><p style="line-height: normal; ">3). 启动squid服务</p><p style="line-height: normal; "># service squid start</p><p style="line-height: normal; ">假定squid安装?usr/local/squid目录?也可?/p><p style="line-height: normal; "># /usr/local/squid/sbin/squid -sD</p><p style="line-height: normal; ">4). 停止squid</p><p style="line-height: normal; ">最安全的停止squid的方法是使用squid -k shutdown命o(h)Q?/p><p style="line-height: normal; "># squid -k shutdown</p><p style="line-height: normal; ">5). 重配|运行中的squidq程</p><p style="line-height: normal; ">在你了解了更多关于squid的知识后Q你?x)发现对squid.conf文g做了许多改动。ؓ(f)了让新设|生效,你可以关闭和重启squid,或者在squidq行Ӟ重配|它?/p><p style="line-height: normal; ">重配|运行中的squid最好的Ҏ(gu)是用squid -k reconfigure命o(h)Q?/p><p style="line-height: normal; "># squid -k reconfigure</p><p style="line-height: normal; ">6). 滚动日志文g</p><p style="line-height: normal; ">除非你在squid.conf里禁止,squid?x)写大量的日志文件。你必须周期性的滚动日志文gQ以L它们变得太大。squid大量的重要信息写入日志Q假如写不进MQsquid?x)发生错误ƈ退出。ؓ(f)了合理控制磁盘空间消耗,在cron里用如下命令:(x)</p><p style="line-height: normal; ">%squid -k rotate</p><p style="line-height: normal; ">例如Q如下Q务接口在每天的早?Ҏ(gu)动日志:(x)</p><p style="line-height: normal; ">0 4 * * * /usr/local/squid/sbin/squid -k rotate</p><p style="line-height: normal; ">该命令做两g事。首先,它关闭当前打开的日志文件。然后,通过在文件名后加数字扩展名,它重命名cache.log,store.log,?access.log。例如,cache.log变成cache.log.0,cache.log.0变成cache.log.1,如此l箋Q滚动到 logfile_rotate选项指定的倹{?/p><p style="line-height: normal; ">squid仅仅保存每个日志文g的最后logfile_rotate版本。更老的版本在重命名q程中被删除。假如你想保存更多的拯Q你需要增加logfile_rotate限制Q或者编写脚本用于将日志文gUd到其他位|?误13.7章关于滚动日志的其他信息?/p><h3>3. 讉K控制CZ</h3><p style="line-height: normal; ">1) 止讉K某个|站</p><p style="line-height: normal; ">在squid配置文g中添加以下acl名称?qing)访问规?q新加载配|文?/p><p style="line-height: normal; ">acl sina dstdomain .sina.com.cn .sina.com<br />http_access deny sina</p><p style="line-height: normal; ">?/p><p style="line-height: normal; ">acl sina dst 58.63.236.26 58.63.236.27 58.63.236.28 58.63.236.29 58.63.236.30 58.63.236.31 58.63.236.32 58.63.236.33 58.63.236.34 58.63.236.35 58.63.236.36 58.63.236.37 58.63.236.38 58.63.236.39 58.63.236.49 58.63.236.50<br />http_access deny sina</p><p style="line-height: normal; ">?/p><p style="line-height: normal; ">acl sina dst www.sina.com.cn<br />http_access deny sina</p><p style="line-height: normal; ">2) 止来自某些IP地址的访?/p><p style="line-height: normal; ">在squid配置文g中添加以下acl名称?qing)访问规?q新加载配|文?/p><p style="line-height: normal; ">acl zhang src 192.168.63.6/32<br />http_access deny zhang</p><p style="line-height: normal; ">3) 止在某些时D访?/p><p style="line-height: normal; ">acl Working_hours MTWHF 08:00-17:00<br />http_access allow Working_hours<br />http_access deny !Working_hours</p>4) 止某个代理客户建立q多q接<p style="line-height: normal; ">acl OverConnLimit maxconn 4 <br />http_access deny OverConnLimit</p><h2><a name="transconf" style="text-decoration: none; color: rgb(81, 191, 224); "></a>? 透明代理</h2><p style="line-height: normal; "><a style="text-decoration: none; color: #4d4d4d; ">q回</a></p><p style="line-height: normal; ">让我们现在来惌一个联机状态,是你有一整组内部|络Q而这个内部网l都是透过 NAT L联机出去的。那么我们谈q,是在一个内部网很大的情况下Q?Proxy 是一个很不错的选择Q因他可以减轻带宽负荷Q不q,遗憾的是Q架?Proxy 的时候,也要使用者在览器上面设|代理!那么有没有办法在『用者不需要在览器上面进行Q何配|,可以实C Proxy 帮助使用者联接InternetQ当然有啦!那就?Transparent Proxy 啦!也有人翻译成『透明代理服务器』,其原理是Q?/p><p style="line-height: normal; ">当用者经q?NAT 服务器来联机q入 Internet Ӟ假如使用?Internet 协议?80 (也就?WWW) Q那么就这个要求交l?Proxy 来工作,以达C理服务器的功能?/p><p style="line-height: normal; "><br />呵呵Q也是_(d)当用者是l过 NAT L联机出去Ӟ只要?NAT L发现『咦Q你是要去读?www 的资料对吧!好!那么q个动作?Proxy L帮你搞定Q』如此一来,使用者根本就不需要在览器上面配|?Proxy 的相兌料,因ؓ(f)q个动作是『由 NAT L自己军_的』,所以只要在 NAT L上面配置妥当卛_Q用者不必配|Q何资料呢Q那么要怎么q行呢?只要两个步骤卛_Q?/p><h3>1. 配置 Proxy LQ?/h3><p style="line-height: normal; ">1) 如果是squid 2.5,需要更改squid配置文g中的下列指o(h):</p><p style="line-height: normal; ">[root@test root]# vi /etc/squid/squid.conf <br />Q?nbsp;<br />httpd_accel_host virtual # 告诉web加速器,针对所有的URL</p><p style="line-height: normal; ">httpd_accel_port 80 # 告诉web加速器Q要监听的端口是80Q?/p><p style="line-height: normal; ">httpd_accel_with_proxy on # q个很重要!因ؓ(f)配置 httpd_accel_host 之后Q?cache 的配|会(x)自动被终止,必须要加上这个配|ؓ(f) on 之后Q才能提?cache 的功能!<br />httpd_accel_uses_host_header on</p><p style="line-height: normal; ">2) 如果是squid 2.6,则只需要更改squid配置文g中的一个指?</p><p style="line-height: normal; ">http_port 192.168.63.50:3128 transparent #192.168.63.50 是squid服务器的地址</p><p style="line-height: normal; ">[root@test root]# squid -k reconfigure</p><h3>2. 配置 NAT L?port map Q?/h3><p style="line-height: normal; ">再来让我们到 NAT L上面看看先,因ؓ(f)需要将 80 q个 port 交给 Proxy ?3128 来帮忙协助,所以你的防火墙 script 必须要加入这一D|行:(x) </p><p style="line-height: normal; ">#iptables -t nat -A PREROUTING -i eth0 -p tcp -s 192.168.62.0/24 --dport 80 -j REDIRECT --to-ports 3128</p><p style="line-height: normal; ">注意一下,那个 eth0 是『你?NAT 对内的网卡』,至于 192.168.62.0/24 则是你的内部|域Q请依照你的L实际状态来配置Q这样一来,(zhn)的 client 端完全不需要进行Q何的配置Q立d可以使用 Proxy 的好处啰</p><h3>3. 配置转发</h3><p style="line-height: normal; ">#echo 1 > /proc/sys/net/ipv4/ip_forward</p><p style="line-height: normal; ">或:(x)</p><p style="line-height: normal; ">#vi /etc/sysctl.conf</p><p style="line-height: normal; ">net_ipv4_forword=1</p><p style="line-height: normal; ">#vi /etc/sysconfig/network</p><p style="line-height: normal; ">FORWARD_IPV4=yes</p><p style="line-height: normal; ">#service network restart</p><h3>4. 配置客户?/h3><p style="line-height: normal; ">另外一台计机作ؓ(f)客户行测试,需要将|关、首选DNS服务器指向设|透明代理的服务器Q清除客L(fng)的浏览器代理讄?/p><h2><a name="reverseconf" style="text-decoration: none; color: rgb(81, 191, 224); "></a>? 反向代理</h2><p style="line-height: normal; "><a style="text-decoration: none; color: #4d4d4d; ">q回</a></p><p style="line-height: normal; ">代理服务器是使用非常普遍的一U将局域网L联入互联|的一U方式,使用代理上网可以节约紧缺的IP地址资源Q而且可以L外部L对内部主机的讉KQ内部|主机免受外部网L的攻凅R但是,如果惌互联|上的主问内部网的主源(例如QWeb站点Q,又想使内部网L免受外部|主机攻击,一般的代理服务是不能实现的Q需要用反向代理来实现?/p><p style="line-height: normal; ">什么是反向代理呢?其实Q反向代理也是通常所说的WEB服务器加速,它是一U通过在繁忙的WEB服务器和Internet之间增加一个高速的WEB~冲服务器(卻I(x)WEB反向代理服务器)来降低实际的WEB服务器的负蝲。典型的l构如下图所C:(x)</p><p style="line-height: normal; ">Web服务器加速(反向代理Q是针对Web服务器提供加速功能的。它作ؓ(f)代理CacheQ但q不针对览器用P而针对一台或多台特定Web服务器(q也是反向代理名U的由来Q。实施反向代理(如上图所C)Q只要将Reverse Proxy Cache讑֤攄在一台或多台Web服务器前端即可。当互联|用戯问某个WEB服务器时Q通过DNS服务器解析后的IP地址是Reverse Proxy Server的IP地址,而非原始Web服务器的IP地址,q时Reverse Proxy Server讑֤充当Web服务器,览器可以与它连接,无需再直接与Web服务器相q。因此,大量Web服务工作量被卸蝲到反向代理服务上。不但能够防止外部网L直接和web服务器直接通信带来的安全隐(zhn),而且能够很大E度上减轻web服务器的负担Q提高访问速度?/p><p style="line-height: normal; ">1Q?Squid反向代理单个后台WEB服务?/p><p style="line-height: normal; "><span style="font-size: 9pt; "><img height="260" src="http://www.linux.gov.cn/netweb/images/reverse_typical.gif" width="230" border="0" alt="" /></span></p><p style="line-height: normal; ">1) 如果WEB服务器和反向代理服务器是两台单独的机器(一般的反向代理应该有两块网卡分别连接了内外部网l)。那么,应该修改下面的内Ҏ(gu)讄反向代理服务?/p><p style="line-height: normal; ">http_port 80 #squid监听的端?br />httpd_accel_host 172.16.250.250 #内部WEB服务器的IP地址<br />httpd_accel_port 80 #WEB服务的端口号<br />httpd_accel_single_host on #转发没有~冲的请求到一台单独的机器Qsquid被设|成仅对单一的web服务器作反向代理<br />httpd_accel_with_proxy on #如果希望squid既作反向代理服务器又作本地机器的上网代理Q需要将此设为onQ默认是off<br />httpd_accel_uses_host_header off #在HTTP协议1.1中,HTTPh包括一个主机头信息Q指定URL的主机名或者主机的IP地址。这个选项可以用来完成多个后台WEB服务器的反向代理功能?/p><p style="line-height: normal; ">2) 如果WEB服务器和反向代理服务器是同一台机器。那么,应该讄WEB服务器的监听端口为非80端口Q比如:(x)81端口Q。要修改的内容如下:(x)</p><p style="line-height: normal; ">http_port 80 #squid监听的端?br />httpd_accel_host localhost #内部WEB服务器的IP地址<br />httpd_accel_port 81 #WEB服务器的端口?br />httpd_accel_single_host on<br />httpd_accel_with_proxy on <br />httpd_accel_uses_host_header off</p><p style="line-height: normal; ">2QSquid反向代理多个后台WEB服务?/p><p style="line-height: normal; ">我们可以用Squid反向代理多个后台WEB服务器。例如:(x)我们可以配置squid同时反向代理www.abc.com, www.xyz.com, www.lmn.com三个后台WEB服务器,C意囑֦下:(x)</p><p style="line-height: normal; "><span style="font-size: 9pt; "><img height="260" src="http://www.linux.gov.cn/netweb/images/reverse_mult.gif" width="230" border="0" alt="" /></span></p><p style="line-height: normal; ">Squid的配|如下:(x)</p><p style="line-height: normal; ">httpd_accel_host virtual<br />httpd_accel_port 80 <br />httpd_accel_single_host off <br />httpd_accel_uses_host_header on</p><p style="line-height: normal; ">Q注?~译Squid旉ȀzInternal DNS选项Q?/p><p style="line-height: normal; ">然后讄讄反响代理需要的域名解析QInternet用户通过q里解析三个|站的域名)如下Q?/p><p style="line-height: normal; ">www.abc.com 202.102.240.74<br />www.xyz.com 202.102.240.74<br />www.lmn.com 202.102.240.74</p><p style="line-height: normal; ">使三个域名都指向反向代理服务器的IP地址202.102.240.74?/p><p style="line-height: normal; ">下面讄反向代理所需要的DNS入口信息Q即讄内部DNSQ仅仅是squid在内部用,Internet用户不可见)。有两种Ҏ(gu)可以讄内部DNSQ用内部DNS服务器来解析或者?etc/hosts文g来实现?/p><p style="line-height: normal; ">使用内部DNS服务器的资源记录如下Q?br />www.abc.com IN A 192.168.62.2<br />www.xyz.com IN A 192.168.62.3<br />www.lmn.com IN A 192.168.62.4</p><p style="line-height: normal; ">如果使用/etc/hosts文g来实现内部DNSQ编译时应用disable internal dns选项Q?~辑/etc/hosts文gd如下条目Q?nbsp;<br />192.168.62.2 www.abc.com<br />192.168.62.3 www.xyz.com<br />192.168.62.4 www.lmn.com</p><p style="line-height: normal; ">l论Q通过本文中的和相兛_例,可以看出Q反向代理方式不单是一UWEB服务器加速器Q而且使也一U对外提供Web发布时用的有效的防火墙技术,使用它不但能节约紧缺的IP地址资源Q加速WEB服务器的讉K速度Q而且能够保护WEBLQ因此能够适应多种应用场合?/p><h2><a name="troubleshoot" style="text-decoration: none; color: rgb(81, 191, 224); "></a>? 故障处理</h2><p style="line-height: normal; "><a style="text-decoration: none; color: #4d4d4d; ">q回</a></p><p style="line-height: normal; ">1. 如果在启动squid时出CqC?</p><p style="line-height: normal; ">% squid -Nd1<br /><br />FATAL: Could not determine fully qualified hostname. Please set 'visible_hostname'</p><p style="line-height: normal; ">则需要在squid的配|文件中讄visible_hostname,?</p><p style="line-height: normal; ">visible_hostname squid.packet-pushers.net</p><p style="line-height: normal; ">2. 如果在配|squid代理?客户讉K出现以下提示:</p><p style="line-height: normal; ">ERROR<br />The requested URL could not be retrieved</p><p style="line-height: normal; ">While trying to retrieve the URL: http://.../</p><p style="line-height: normal; ">可能需要在squid配置文g中加入以下指?</p><p style="line-height: normal; ">always_direct allow all</p><h2><a name="example1" style="text-decoration: none; color: rgb(81, 191, 224); "></a>? 一个范?/h2><p style="line-height: normal; "><a style="text-decoration: none; color: #4d4d4d; ">q回</a></p><p style="line-height: normal; ">http_port 3128<br />icp_port 0</p><p style="line-height: normal; ">cache_mem 64 MB<br />cache_swap_low 80<br />cache_swap_high 85</p><p style="line-height: normal; ">maximum_object_size 32000 KB</p><p style="line-height: normal; ">cache_dir ufs /var/spool/squid 500 64 1024<br />cache_access_log /var/log/squid/access.log<br />cache_log /var/log/squid/cache.log<br />cache_store_log /var/log/squid/store.log</p><p style="line-height: normal; ">pid_filename /var/run/squid.pid</p><p style="line-height: normal; ">acl all src 0.0.0.0/0.0.0.0<br />acl alldst dst 0.0.0.0/0.0.0.0<br />acl manager proto cache_object<br />acl localhost src 127.0.0.1/255.255.255.255<br />acl to_localhost dst 127.0.0.0/8<br />acl 163 url_regex 163.com<br />acl sina url_regex sina.com.cn<br />acl myclient src 192.168.6.0/24</p><p style="line-height: normal; ">http_access allow 163<br />http_access allow sina<br />http_access deny !sina<br />http_access deny !163</p><p style="line-height: normal; ">cache_peer 192.168.1.8 parent 8080 7 no-query default</p><p style="line-height: normal; ">cache_effective_user squid<br />cache_effective_group squid<br />cache_mgr root@net03.org<br />coredump_dir /var/spool/squid</p><h2><a name="example2" style="text-decoration: none; color: rgb(81, 191, 224); "></a>? 一个限制访问的范例</h2><p style="line-height: normal; "><a style="text-decoration: none; color: #4d4d4d; ">q回</a></p><p style="line-height: normal; ">http_port 3128<br />icp_port 0<br />cache_mem 64 MB<br />cache_swap_low 80<br />cache_swap_high 85<br />maximum_object_size 32000 KB<br />cache_dir ufs /var/spool/squid 500 64 1024<br />cache_access_log /var/log/squid/access.log<br />cache_log /var/log/squid/cache.log<br />cache_store_log /var/log/squid/store.log<br />pid_filename /var/run/squid.pid<br />acl all src 0.0.0.0/0.0.0.0<br />acl manager proto cache_object<br />acl localhost src 127.0.0.1/255.255.255.255<br />acl to_localhost dst 127.0.0.0/8<br />acl SSL_ports port 443 563<br />acl Safe_ports port 80 # http<br />acl Safe_ports port 21 # ftp<br />acl Safe_ports port 443 563 # https, snews<br />acl Safe_ports port 70 # gopher<br />acl Safe_ports port 210 # wais<br />acl Safe_ports port 1025-65535 # unregistered ports<br />acl Safe_ports port 280 # http-mgmt<br />acl Safe_ports port 488 # gss-http<br />acl Safe_ports port 591 # filemaker<br />acl Safe_ports port 777 # multiling http<br />acl CONNECT method CONNECT<br />acl myclient src 192.168.6.0/24<br />acl 163 url_regex 163.com<br />acl sina url_regex sina.com.cn<br /># Only allow cachemgr access from localhost<br />http_access allow manager localhost<br />http_access deny manager<br /># Deny requests to unknown ports<br />http_access deny !Safe_ports<br /># Deny CONNECT to other than SSL ports<br />http_access deny CONNECT !SSL_ports</p><p style="line-height: normal; ">cache_peer 192.168.1.8 parent 8080 7 no-query default</p><p style="line-height: normal; ">acl ip_acl src 192.168.6.0/24<br />acl time_acl time M T W H F A S 9:00-19:00<br />http_access allow ip_acl time_acl</p><p style="line-height: normal; ">cache_peer_access 192.168.1.8 allow 163<br />cache_peer_access 192.168.1.8 deny !163<br />cache_peer_access 192.168.1.8 allow sina<br />cache_peer_access 192.168.1.8 deny !sina</p><p style="line-height: normal; ">cache_effective_user squid<br />cache_effective_group squid<br />cache_mgr root@net03.org<br />coredump_dir /var/spool/squid</p><p style="line-height: normal; ">#acl pl800_arp arp 00:08:c7:9f:34:41<br />#http_access allow pl800_arp</p></div></td></tr></tbody></table><img src ="http://www.shnenglu.com/larryliuqing/aggbug/163474.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/larryliuqing/" target="_blank">刘远?/a> 2012-01-03 11:54 <a href="http://www.shnenglu.com/larryliuqing/archive/2012/01/03/163474.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.squc.cn" target="_blank">þ99žŹѿС˵</a>| <a href="http://www.u4439.cn" target="_blank">ŷ޳ҹƷþ</a>| <a href="http://www.vdzy.cn" target="_blank">Ʒһþ</a>| <a href="http://www.liangz.cn" target="_blank">þ¾Ʒ</a>| <a href="http://www.888su.cn" target="_blank">ɫ8ŷ˾þۺϵ</a>| <a href="http://www.aoaya.cn" target="_blank">þþƷ99Ʒ </a>| <a href="http://www.jianfeiyaow.cn" target="_blank">þ99Ʒþþþþò</a>| <a href="http://www.bbdhtex.cn" target="_blank">þþƷĻ23ҳ</a>| <a href="http://www.mizhewang.cn" target="_blank">鶹þþ9ԴƬ</a>| <a href="http://www.chaohu8.cn" target="_blank">þó˾ƷƵ</a>| <a href="http://www.ssc629.cn" target="_blank">þþþþþŮú</a>| <a href="http://www.d13722.cn" target="_blank">˾þô߽槼</a>| <a href="http://www.fengdingjun.cn" target="_blank">Ժձһձþ </a>| <a href="http://www.vdmo.cn" target="_blank">Ů޾Ʒþþۺ</a>| <a href="http://www.yhlj.net.cn" target="_blank">þþƷĻ̾</a>| <a href="http://www.imlee.com.cn" target="_blank">þþƷŷպþ</a>| <a href="http://www.0731car.com.cn" target="_blank">ɫ͵͵͵þ˴ý</a>| <a href="http://www.celtictree.cn" target="_blank">þþ</a>| <a href="http://www.dqcz.net.cn" target="_blank">2021ٸþþþþþþþ</a>| <a href="http://www.aigoua.cn" target="_blank">þþžѾƷ6</a>| <a href="http://www.itsidekick.cn" target="_blank">þ996ȾƷxxxx</a>| <a href="http://www.chemzt.cn" target="_blank">þþþùһëƬ</a>| <a href="http://www.abcdds.cn" target="_blank">޾Ʒһþ</a>| <a href="http://www.4000300252.cn" target="_blank">þ¶Ʒ</a>| <a href="http://www.88177.com.cn" target="_blank">޹þ</a>| <a href="http://www.magifts.cn" target="_blank">ƷŮþþ</a>| <a href="http://www.hkgsjt.cn" target="_blank">þþƷרѶ </a>| <a href="http://www.zhongshengwsl.cn" target="_blank">Ʒ˾þþþҹӰ</a>| <a href="http://www.lianliankan123.cn" target="_blank">Ʒþþ㽶</a>| <a href="http://www.uutools.cn" target="_blank">ҹҹþݺ</a>| <a href="http://www.tzfxw.cn" target="_blank">þ99ۺϾƷҳ</a>| <a href="http://www.rongchenjiaxiao.cn" target="_blank">þ99ƷۺϹҳ</a>| <a href="http://www.ptmei.cn" target="_blank">þþþþþۺ </a>| <a href="http://www.aion66.cn" target="_blank">88þþƷһëƬ</a>| <a href="http://www.oq21.cn" target="_blank">þþƷ99þþ</a>| <a href="http://www.drlf.net.cn" target="_blank">þüۺɫۺϰҲȥ</a>| <a href="http://www.n-hao.cn" target="_blank">޹Ʒþһ</a>| <a href="http://www.ireboot.cn" target="_blank">vaþþþ</a>| <a href="http://www.hy-exp.cn" target="_blank">˾þþƷavһ</a>| <a href="http://www.a79wvh.cn" target="_blank">ɫ8þ97㽶987</a>| <a href="http://www.lxlfhq.cn" target="_blank">þþƷAVũ帾Ů</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>