⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 860.html

📁 著名的linux英雄站点的文档打包
💻 HTML
📖 第 1 页 / 共 3 页
字号:
3.解开该文件 tar xvzf squid-2.3.STABLE2-src.tar.gz。 <br>
4.解开后,在/usr/local生成一个新的目录squid-2.3.STABLE2,为了方便用mv命令将 该目录重命名为squid mv squid-2.3.STABLE2 squid; <br>
5.进入squid cd squid <br>
6.执行./configure 可以用./confgure --prefix=/directory/you/want指定安装目录 <br>
系统缺省安装目录为/usr/local/squid。 <br>
7.执行 make all <br>
8.执行 make install <br>
9.安装结束后,squid的可执行文件在安装目录的bin子目录下,配置文件在etc子目录下。 <br>
<br>
3.2 配置squid <br>
由于RedHat各方面的优势(包括易用性,稳定性等等),全世界范围内使用该发行版的用户比较多,所以,我们下面的说明都是以 RedHat6.1环境下squid-2.2.STABLE4-8版本为主。从我的使用经验看来,该版本的squid要比其他版本稳定的多,以前的 1.1.22版本也比较稳定,但是在功能及灵活性方面有所欠缺。 <br>
squid有一个主要的配置文件squid.conf,在RedHat环境下所有squid的配置文件位于/etc/squid子目录下。 <br>
<br>
1.常用的配置选项 <br>
因为缺省的配置文件有问题,所以我们必须首先修改该配置文件的有关内容,以便让squid跑起来。 <br>
下面我们来看一看一些常用的选项: <br>
1.http_port <br>
说明:定义squid监听HTTP客户连接请求的端口。缺省是3128,如果使用HTTPD加速模式 则为80。你可以指定多个端口,但是所有指定的端口都必须在一条命令行上。 <br>
<br>
2.cache_mem (bytes) <br>
说明:该选项用于指定squid可以使用的内存的理想值。这部分内存被用来存储以下对象 : <br>
In-Transit objects (传入的对象) <br>
Hot Objects (热对象,即用户常访问的对象) <br>
Negative-Cached objects (消极存储的对象) <br>
需要注意的是,这并没有指明squid所使用的内存一定不能超过该值,其实,该选项只 定义了squid所使用的内存的一个方面,squid还在其他方面使用内存。所以squid实际 使用的内存可能超过该值。缺省值为8MB。 <br>
<br>
3.cache_dir Directory-Name Mbytes Level-1 Level2 <br>
说明:指定squid用来存储对象的交换空间的大小及其目录结构。可以用多个cache_dir命令来定义多个这样的交换空间,并且这些交换空间可以分布不同的磁盘分区。"directory "指明了该交换空间的顶级目录。如果你想用整个磁盘来作为交换空间,那么你可以将该目录作为装载点将整个磁盘mount上去。缺省值为/var/spool/squid。"Mbytes"定义了可用的空间总量。需要注意的是,squid进程必须拥有对该目录的读写权力。"Level-1"是可以在该顶级目录下建立的第一级子目录的数目,缺省值为16。同理,"Level-2"是可以建立的第二级子目录的数目,缺省值为256。为什么要定义这么多子目录呢?这是因为如果子目录太少,则存储在一个子目录下的文件数目将大大增加,这也会导致系统寻找某一个文件的时间大大增加,从而使系统的整体性能急剧降低。所以,为了减少每个目录下的文件数量,我们必须增加所使用的目录的数量。如果仅仅使用一级子目录则顶级目录下的子目录数目太大了,所以我们使用两级子目录结构。 <br>
那么,怎么来确定你的系统所需要的子目录数目呢?我们可以用下面的公式来估算。 <br>
已知量: <br>
DS = 可用交换空间总量(单位KB)/ 交换空间数目 <br>
OS = 平均每个对象的大小= 20k <br>
NO = 平均每个二级子目录所存储的对象数目 = 256 <br>
<br>
未知量: <br>
L1 = 一级子目录的数量 <br>
L2 = 二级子目录的数量 <br>
<br>
计算公式: <br>
L1 x L2 = DS / OS / NO <br>
注意这是个不定方程,可以有多个解。 <br>
<br>
4.acl <br>
说明:定义访问控制列表。 <br>
定义语法为: <br>
acl aclname acltype string1 ... <br>
acl aclname acltype "file" ... <br>
当使用文件时,该文件的格式为每行包含一个条目。 <br>
acltype 可以是 src dst srcdomain dstdomain url_pattern urlpath_pattern time port proto method browser user 中的一种。 <br>
分别说明如下: <br>
src 指明源地址。可以用以下的方法指定: <br>
acl aclname src ip-address/netmask ... (客户ip地址) <br>
acl aclname src addr1-addr2/netmask ... (地址范围) <br>
dst 指明目标地址。语法为: <br>
acl aclname dst ip-address/netmask ... (即客户请求的服务器的ip地址) <br>
srcdomain 指明客户所属的域。语法为: <br>
acl aclname srcdomain foo.com ... squid将根据客户ip反向查询DNS。 <br>
dstdomain 指明请求服务器所属的域。语法为: <br>
acl aclname dstdomain foo.com ... 由客户请求的URL决定。 <br>
注意,如果用户使用服务器ip而非完整的域名时,squid将进行反向的DNS解析来确 定其完整域名,如果失败就记录为"none"。 <br>
time 指明访问时间。语法如下: <br>
acl aclname time [day-abbrevs] [h1:m1-h2:m2][hh:mm-hh:mm] <br>
day-abbrevs: <br>
S - Sunday <br>
M - Monday <br>
T - Tuesday <br>
W - Wednesday <br>
H - Thursday <br>
F - Friday <br>
A - Saturday <br>
h1:m1 必须小于 h2:m2,表达示为[hh:mm-hh:mm]。 <br>
port 指定访问端口。可以指定多个端口,比如: <br>
acl aclname port 80 70 21 ... <br>
acl aclname port 0-1024 ... (指定一个端口范围) <br>
proto 指定使用协议。可以指定多个协议: <br>
acl aclname proto HTTP FTP ... <br>
method 指定请求方法。比如: <br>
acl aclname method GET POST ... <br>
<br>
5.http_access <br>
说明:根据访问控制列表允许或禁止某一类用户访问。 <br>
如果某个访问没有相符合的项目,则缺省为应用最后一条项目的"非"。比如最后一条为允许,则缺省就是禁止。所以,通常应该把最后的条目设为"deny all" 或 "allow all" 来避免安全性隐患。 <br>
<br>
3.3启动、停止squid。 <br>
配置并保存好squid.conf后,可以用以下命令启动squid。 <br>
squid <br>
或者,使用RedHat的启动脚本来启动squid. <br>
/etc/rc.d/init.d/squid start <br>
同样地,你也可以用下列脚本停止运行squid或重启动squid. <br>
/etc/rc.d/init.d/squid stop <br>
/etc/rc.d/init.d/squid restart <br>
<br>
<br>
4. 透明代理 <br>
关于透明代理的概念我们已经在第一节将过了,下面我们看一下怎么样在squid中实现透明代理。 <br>
透明代理的实现需要在Linux 2.0.29以上,但是Linux 2.0.30并不支持该功能,好在我们现在使用的通常是2.2.X以上的版本,所以不必担心这个问题。下面我们就用ipchains+squid来实现透明代理。在开始之前需要说明的是,目前我们只能实现支持HTTP的透明代理,但是也不必太担心,因为我们之所以使用代理,目的是利用squid的缓存来提高Web的访问速度,至于提供内部非法ip地址的访问及提高网络安全性,我们可以用ipchains来解决。 <br>
实现环境:RedHat6.x+squid2.2.x+ipchains <br>
4.1 linux的相关配置 <br>
确定你的内核已经配置了支持透明代理解的相关特性,如果没有,请你重新编译内核。一般在RedHat6.x以上,系统已经缺省配置了这些特性。 <br>
4.2squid的相关配置选项 <br>
设置squid.conf中的相关选项,如下所示: <br>
http_port 3218 <br>
httpd_accel_host virtual <br>
httpd_accel_port 80 <br>
httpd_accel_with_proxy on <br>
httpd_accel_uses_host_header on <br>
说明: <br>
1.http_port 3128 <br>
在本例中,我们假设squid的HTTP监听端口为3128,即squid缺省设置值。然后,把所有来自于客户端web请求的包(即目标端口为80)重定向到3128端口。 <br>
2.httpd_accel_host virtual <br>
httpd_accel_port 80 <br>
这两个选项本来是用来定义squid加速模式的。在这里我们用virtual来指定为虚拟主机模式。80端口为要加速的请求端口。采用这种模式时,squid就取消了缓存及ICP功能,假如你需要这些功能,这必须设置httpd_accel_with_proxy选项。 <br>
3.httpd_accel_with_proxy on <br>
该选项在透明代理模式下是必须设置成on的。在该模式下,squid既是web请求的加速器,又是缓存代理服务器。 <br>
4.httpd_accel_uses_host_header on <br>
在透明代理模式下,如果你想让你代理服务器的缓存功能正确工作的话,你必须将该选项设为on。设为on时,squid会把存储的对象加上主机名而不是ip地址作为索引。这一点在你想建立代理服务器阵列时显得尤为重要。 <br>
<br>
4.3 ipchains的相关配置 <br>
ipchains在这里所起的作用是端口重定向。我们可以使用下列语句实现将目标端口为80端口的TCP包重定向到3128端口。 <br>
<br>
#接收所有的回送包 <br>
/sbin/ipchains -A input -j ACCEPT -i lo <br>
#将目标端口为80端口的TCP包重定向到3128端口 <br>
/sbin/ipchains -A input -p tcp -d 0.0.0.0/0 80 -j REDIRECT 80 <br>
<br>
当然在这以前,我们必须用下面的语句打开包转发功能。 <br>
echo 1 &gt; /proc/sys/net/ipv4/ip_forward<br>
</FONT><br>
                                      </TD>
                                    </TR>
                                <TR>
                                <TD colSpan=2><FONT 
                                class=middlefont></FONT><BR>
                                        <FONT 
                                class=normalfont>全文结束</FONT> </TD>
                                    </TR>
                                <TR>
                                <TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2 
                                height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
                        <TD vAlign=top width="20%" 
                      background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2> 
                          <DIV align=center> 
                            <table class=tableoutline cellspacing=1 cellpadding=4 
                        width="100%" align=center border=0>
                              <tr class=firstalt> 
                                <td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
                                <font class=normalfont><b>所有分类</b></font></td>
                              </tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td>    </tr>  </table></td></tr>                            </table>
                          </DIV></TD></TR>
                    <TR vAlign=top>
                        <TD width="80%"> 
                          <DIV align=center><BR>
                          </DIV>
                        </TD></TR></TBODY></TABLE></TD></TR>
                </TABLE></TD></TR>
          </TABLE>
      <TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee 
        border=0><TBODY>
        <TR>
          <TD width="50%">
              <P><FONT class=middlefont>版权所有 &copy; 2004 <A 
            href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
                违者必究. </FONT></P>
            </TD>
          <TD width="50%">
              <DIV align=right><FONT class=middlefont>Powered by: <A 
            href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
            </TD></TR></TBODY></TABLE>
      <CENTER></CENTER></TD></TR>
    </TABLE></CENTER></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -