{"id":153,"date":"2010-12-10T23:44:45","date_gmt":"2010-12-10T15:44:45","guid":{"rendered":"http:\/\/www.microwolf.net\/?p=153"},"modified":"2010-12-10T23:44:45","modified_gmt":"2010-12-10T15:44:45","slug":"linux-%e4%b8%8b%e6%9e%b6%e8%ae%be-squid-%e7%bc%93%e5%ad%98%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"http:\/\/www.microwolf.net\/?p=153","title":{"rendered":"Linux \u4e0b\u67b6\u8bbe Squid \u7f13\u5b58\u4ee3\u7406\u670d\u52a1\u5668"},"content":{"rendered":"<table border=\"0\" width=\"100%\">\n<tr>\n<td width=\"100%\">\u7f13\u5b58\u4ee3\u7406\u670d\u52a1\u5668Squid<\/p>\n<p>\n      &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>\n      Squid\u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684\u4ee3\u7406\u7f13\u51b2\u670d\u52a1\u5668\uff0c\u4e5f\u8bb8\u4f60\u5df2\u7ecf\u7528\u8fc7Windows\u5e73\u53f0\u4e0b\u7684WinGate\uff0cMS Proxy Server\u7b49\u529f\u80fd\u7c7b\u4f3c\u7684\u4ea7\u54c1\u3002Squid\u662f\u4e00\u4e2a\u5e94\u7528\u7ea7\u4ee3\u7406\uff0c\u5728\u4fdd\u8bc1\u5ba2\u6237\u7aef\u4e3b\u673a\u548c\u670d\u52a1\u5668\u4e3b\u673a\u7f51\u7edc\u8fde\u901a\u540e\uff0c\u9700\u8981\u5ba2\u6237\u7aef\u8f6f\u4ef6\u505a\u76f8\u5e94\u7684\u8bbe\u7f6e\u540e\u624d\u80fd\u4f7f\u7528\uff0c\u6bd4\u5982\u7ed9Internet Explorer\u8bbe\u7f6e\u4ee3\u7406\u670d\u52a1\u5668\u5730\u5740\u3001\u7aef\u53e3\u7b49\u3002<\/p>\n<p>\n      WEB\u7f13\u5b58\u529f\u80fd\u5bf9\u4e8e\u4e00\u4e2a\u89c4\u6a21\u8f83\u5927\u3001\u8bbf\u95ee\u7e41\u5fd9\u7684\u7f51\u7edc\u6765\u8bf4\u662f\u6709\u5fc5\u8981\u7684\uff0cIBM\u7f51\u7ad9\u4e0a\u7684\u4e00\u7bc7\u6587\u7ae0\uff0c\u8be6\u7ec6\u5206\u6790\u4ecb\u7ecd\u4e86WEB\u7f13\u5b58\u7ed9\u4e0a\u7f51\u7528\u6237\u5e26\u6765\u7684\u597d\u5904\uff1a<\/p>\n<p>      http:\/\/www-900.ibm.com\/developerWorks\/cn\/web\/webcachinga\/index.shtml<\/p>\n<p>\n      \u4e0b\u9762\u6211\u4eec\u5c31\u4ecb\u7ecd\u4e00\u4e0bsquid\u7684\u6709\u5173\u5185\u5bb9\u3002<\/p>\n<p>\n      \u00a7\u00a7\u3000\u5b89\u88c5\u8fd0\u884csquid<\/p>\n<p>\n      Redhat 7.3\u81ea\u5e26Squid\u7684rpm\u5305squid-2.4.STABLE6-1.7.2.i386.rpm\uff0c\u8fd9\u91cc\u6211\u4eec\u76f4\u63a5\u5229\u7528rpm\u6765\u5b89\u88c5Squid\uff1a<\/p>\n<p>\n      [root@rh73 \/mnt\/cdrom\/RedHat\/RPMS]# rpm -ivh squid-2.4.STABLE6-1.7.2.i386.rpm<\/p>\n<p>      Preparing&#8230;                ########################################### [100%]<\/p>\n<p>   1:squid                  ########################################### [100%]<\/p>\n<p>      \u5b89\u88c5\u540e\u7684Squid\u914d\u7f6e\u6587\u4ef6\u5728\/etc\/squid\/\u76ee\u5f55\u4e0b\uff0c\u53ea\u9700\u8981\u7b80\u5355\u7684\u914d\u7f6e\u4e00\u4e0b\/etc\/squid\/squid.conf\u5c31\u53ef\u4ee5\u8ba9\u5b83\u5de5\u4f5c\u8d77\u6765\u4e86\u3002<\/p>\n<p>\n      \u9ed8\u8ba4\u5b89\u88c5\u7684Squid\u914d\u7f6e\u6587\u4ef6\u662f\u4e00\u4e2a\u4e24\u5343\u591a\u884c\u7684\u6587\u672c\uff0c\u5b9e\u4e8b\u4e0a\u4f60\u7528\u4e0d\u5230\u8bbe\u7f6e\u90a3\u4e48\u591a\u3002\u7528\u7f16\u8f91\u5668\u6253\u5f00\u8be5\u914d\u7f6e\u6587\u4ef6\uff0c\u627e\u5230http_access\u8bbe\u7f6e\u90e8\u5206\uff0c\u628a<\/p>\n<p>      http_access deny all<\/p>\n<p>      \u4e00\u884c\u6539\u6210<\/p>\n<p>      http_access allow all       <\/p>\n<p>\u8bbe\u7f6e\u7f13\u5b58\u76ee\u5f55<\/p>\n<p>squid -z<\/p>\n<p>\n      \u7136\u540e\u542f\u52a8Squid\uff1a<\/p>\n<p>      \/etc\/rc.d\/init.d\/squid start<\/p>\n<p>\u6216<\/p>\n<p>service squid start<\/p>\n<p>\n      \u73b0\u5728\u4f60\u7684Squid\u4ee3\u7406\u670d\u52a1\u5668\u5df2\u7ecf\u53ef\u4ee5\u4f7f\u7528\u4e86\u3002\u5230\u5ba2\u6237\u7aef\u8bbe\u7f6e\u4e0a\u7f51\u8f6f\u4ef6\u7684\u4ee3\u7406\u9009\u9879\uff0c\u4ee5Internet Explorer 6.0\u4e3a\u4f8b\uff0c\u5728Internet\u5c5e\u6027\u8bbe\u7f6e\u91cc\u8bbe\u7f6e\u201c\u8fde\u63a5\u201d\u5c5e\u6027\uff0c\u70b9\u201c\u5c40\u57df\u7f51\u8bbe\u7f6e\u201d\u6309\u94ae\uff1a<\/p>\n<p>      \u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\u9009\u4e2d\u201c\u4e3aLAN\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u201d\uff0c\u5728\u5730\u5740\u680f\u586b\u5165\u4ee3\u7406\u670d\u52a1\u5668\u5730\u5740\uff0c\u8fd9\u91cc\u662f\uff1a192.168.100.254\uff0c\u7aef\u53e3\u4e3asquid\u9ed8\u8ba4\u76843128\uff1a<\/p>\n<p>      \u786e\u8ba4\u3002\u6b64\u65f6\u4f60\u518d\u7528Internet Explorer\u4e0a\u7f51\u4fbf\u662f\u4f7f\u7528squid\u4ee3\u7406\u3002\u4f60\u53ef\u4ee5\u5bdf\u770bsquid\u7684log\u6587\u4ef6\u6765\u89c2\u5bdf\u5230\u5ba2\u6237\u7aef\u4e3b\u673a\u901a\u8fc7squid\u7684\u8bbf\u95ee\u60c5\u51b5\uff1a<\/p>\n<p>      [root@rh73 ~]# tail -f \/var\/log\/squid\/access.log<\/p>\n<p>      \u5728\u8fd9\u91cc\uff0c\u4e0a\u9762\u7684\u8bbe\u7f6e\u53ea\u5bf9Internet Explorer\u8d77\u4f5c\u7528\u3002\u5982\u679c\u4f60\u6309\u7167\u524d\u9762\u7684\u7ae0\u8282\u5728Linux\u63a5\u5165\u670d\u52a1\u5668\u4e0a\u5b9e\u73b0\u4e86NAT\u7684\u529f\u80fd\uff0c\u9664\u4e86IE\u6d4f\u89c8\u5668\u91cc\u8bbf\u95eehttp\u3001ftp\u670d\u52a1\u662f\u5728\u7528squid\u4ee3\u7406\u5916\uff0c\u5176\u5b83\u4e0a\u8bbf\u95eeInternet\u7684\u64cd\u4f5c\uff0c\u5982\u6536\u53d1Email\uff0ctelnet\uff0c\u8fd8\u662f\u901a\u8fc7NAT\u5b8c\u6210\u8bbf\u95ee\u3002\u5f53\u4f60\u628a\u6d4f\u89c8\u5668\u7684\u4ee3\u7406\u8bbe\u7f6e\u9009\u9879\u6e05\u9664\u540e\uff0c\u4f60\u53c8\u53ef\u4ee5\u6062\u590d\u5230NAT\u65b9\u5f0f\u8bbf\u95eeInternet\u3002<\/p>\n<p>\n      \u00a7\u00a7\u3000\u8bbe\u7f6esquid<\/p>\n<p>\n      \u524d\u9762\u7684\u914d\u7f6e\u662f\u4e0d\u52a0\u9650\u5236\u7684\u5141\u8bb8\u5185\u90e8\u6240\u6709\u7528\u6237\u4f7f\u7528\u8be5\u4ee3\u7406\u4e0aInternet\uff0c\u663e\u7136\u8fd9\u4e0d\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u8bbf\u95ee\u7b56\u7565\u3002\u6211\u4eec\u8bf4\u8fc7\uff0c\u4ee3\u7406\u65b9\u5f0f\u5bf9\u7528\u6237\u6743\u9650\u7684\u63a7\u5236\u6709\u7740\u975e\u5e38\u4e30\u5bcc\u7684\u652f\u6301\u3002\u4e0b\u9762\u5c31\u770b\u770bsquid\u5982\u4f55\u5b9e\u73b0\u591a\u6837\u5316\u7684\u6743\u9650\u63a7\u5236\u7684\u3002<\/p>\n<p>      \u8ba9\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0bsquid.conf\u7684\u51e0\u4e2a\u914d\u7f6e\u9009\u9879\u548c\u8bbf\u95ee\u63a7\u5236\u7279\u6027\uff1a<\/p>\n<p>      Squid \u7684\u5b9a\u5236\u662f\u901a\u8fc7\u8bbe\u7f6e\u5b83\u7684\u914d\u7f6e\u6587\u4ef6 squid.conf \u6765\u5b9e\u73b0\u7684\uff0csquid.conf \u6587\u4ef6\u901a\u5e38\u5728 \/etc\/squid \u76ee\u5f55\u4e0b\u3002\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5f88\u591a\uff0c\u4f46\u5b83\u7684\u6bcf\u4e2a\u9009\u9879\u90fd\u6709\u8be6\u5c3d\u7684\u8bf4\u660e\u3002\u4e0b\u9762\u662f\u51e0\u4e2a\u5e38\u7528\u7684\u914d\u7f6e\u53c2\u6570\uff1a<\/p>\n<p>      http_port<\/p>\n<p>      \u9996\u5148\u6765\u66f4\u6539\u4e00\u4e0b http_port\uff0c\u8fd9\u4e2a\u9009\u9879\u6307\u5b9a\u4e86 Squid \u76d1\u542c\u5ba2\u6237\u8bf7\u6c42\u7684\u7aef\u53e3\uff0c\u9ed8\u8ba4\u503c\u662f 3128\u3002\u8981\u4f7f\u7528\u4ee3\u7406\u529f\u80fd\uff0c\u5efa\u8bae\u8fd9\u4e2a\u7aef\u53e3\u503c\u548c\u8fd0\u884c Squid \u7684\u673a\u5668\u7684 IP \u5730\u5740\u4e00\u8d77\u4f7f\u7528\uff0c\u53ef\u4ee5\u4fee\u6539\u6210\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n<p>      http_port 192.168.100.254:3128<\/p>\n<p>      \u4e0a\u8ff0\u58f0\u660e\u8868\u793a Squid \u7ed1\u5b9a\u5728 IP \u5730\u5740 192.168.100.254 \u4e0a\uff0c\u7aef\u53e3\u4e3a 3128\u3002\u7aef\u53e3\u53ef\u4ee5\u8bbe\u7f6e\u4e3a\u4efb\u610f\u503c\uff0c\u4f46\u8981\u786e\u8ba4\u6ca1\u6709\u5176\u4ed6\u7a0b\u5e8f\u4f1a\u4f7f\u7528\u540c\u6837\u7684\u7aef\u53e3\u3002\/etc\/services\u6587\u4ef6\u5217\u51fa\u4e86\u5e38\u7528\u7aef\u53e3\uff0c\u5982\u679c\u4f60\u60f3\u4e3asquid\u8bbe\u7f6e\u5176\u5b83\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u53c2\u8003\u8fd9\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u9632\u6b62\u91cd\u590d\u8bbe\u7f6e\u3002<\/p>\n<p>\n      visible_hostname 192.168.100.254<\/p>\n<p>      \u8fd0\u884csquid\u7684\u4e3b\u673a\u7684\u540d\u5b57\uff0c\u53ef\u4ee5\u5199\u4e0a\u8be5\u673a\u5668\u7684IP\u5730\u5740\u3002<\/p>\n<p>      cache_mgr pangty@usa.net<\/p>\n<p>      \u7ba1\u7406\u5458\u7684\u90ae\u4ef6\u5730\u5740\u3002\u5728\u8bbf\u95ee\u53d1\u751f\u9519\u8bef\u65f6\uff0cvisible_hostname\u548ccache_mgr\u8fd9\u4e24\u4e2a\u9009\u9879\u7684\u503c\u663e\u793a\u5728\u9519\u8bef\u63d0\u793a\u9875\u9762\u5185\u7684\u76f8\u5173\u4f4d\u7f6e\u3002<\/p>\n<p>      cache_mem 16 MB<\/p>\n<p>      \u5b9a\u4e49\u7f13\u5b58\u5185\u5b58\uff0c\u9ed8\u8ba4\u8bbe\u7f6e\u4e3a8MB\u3002\u8fd9\u53ea\u662f\u7f13\u5b58\u5927\u5c0f\uff0c\u7a0b\u5e8f\u8fd0\u884c\u8fd8\u8981\u5b58\u5185\u5b58\uff0c\u4e5f\u5c31\u662f\u8bf4\u4f7f\u7528\u7684\u5185\u5b58\u662f\u5927\u4e8e\u8fd9\u4e2a\u6570\u7684\uff0c\u5982\u679c\u67091G\u5185\u5b58\uff0c\u5b8c\u5168\u53ef\u4ee5\u8bbe\u7f6e\u4e3a128M<\/p>\n<p>      cache_dir Type Directory-Name Fs-specific-data [options]<\/p>\n<p>      \u5b9a\u4e49\u786c\u76d8\u7f13\u5b58\u7a7a\u95f4\u4ee5\u5b58\u50a8\u8bbf\u95ee\u8fc7\u7684\u9875\u9762\u6216\u5176\u5b83\u8d44\u6e90\u7684\u62f7\u8d1d\u3002Type\u662f\u6307\u5b58\u50a8\u7c7b\u578b\uff0c\u4e00\u822c\u8bbe\u7f6e\u4e3aufs\u3002Directort-Name\u4ee3\u8868\u7f13\u5b58\u7684\u4f4d\u7f6e\uff0c\u9ed8\u8ba4\u7684\u8bbe\u7f6e\u662fcache_dir ufs \/var\/spool\/squid 100 16 256\u3002\u5176\u4e2d100\u4ee3\u8868\u7f13\u5b58\u7a7a\u95f4\u6700\u5927\u4e3a100M\uff1b16\u548c256\u4ee3\u8868\u7f13\u5b58\u76ee\u5f55\u4e0b\u7684\u4e00\u7ea7\u548c\u4e8c\u7ea7\u76ee\u5f55\u6570\u3002<\/p>\n<p>      \u8bbf\u95ee\u63a7\u5236<\/p>\n<p>      \u63a7\u5236\u7528\u6237\u7684\u8bbf\u95ee\u6743\u9650\u7b49\u529f\u80fd\u662f\u4f7f\u7528squid\u7684\u8bbf\u95ee\u63a7\u5236\u7279\u6027\u6765\u5b9e\u73b0\u7684\u3002Squid \u8bbf\u95ee\u63a7\u5236\u6709\u4e24\u4e2a\u8981\u7d20\uff1aACL\u548c\u8bbf\u95ee\u5217\u8868\u3002\u8bbf\u95ee\u5217\u8868\u53ef\u4ee5\u5141\u8bb8\u6216\u62d2\u7edd\u67d0\u4e9b\u7528\u6237\u5bf9\u7279\u5b9a\u670d\u52a1\u7684\u8bbf\u95ee\u3002<\/p>\n<p>\n      \u4e3a\u4e86\u4f7f\u7528\u63a7\u5236\u529f\u80fd\uff0c\u5fc5\u987b\u5148\u8bbe\u7f6e ACL\u3002ACL \u58f0\u660e\u7684\u683c\u5f0f\u5982\u4e0b\uff1a <\/p>\n<p>      acl   acl_element_name   type_of_acl_element values_to_acl<\/p>\n<p>\n      \u4e0b\u9762\u5217\u51fa\u4e00\u4e9b\u91cd\u8981\u7684 ACL\u7c7b\u578b\uff08type_of_acl_element\uff09<\/p>\n<p>      l         src : \u6e90\u5730\u5740\uff08\u5373\u5ba2\u6237\u673aIP\u5730\u5740\uff09<\/p>\n<p>      l         dst : \u76ee\u6807\u5730\u5740\uff08\u5373\u670d\u52a1\u5668IP\u5730\u5740\uff09<\/p>\n<p>      l         srcdomain : \u6e90\u540d\u79f0 \uff08\u5373\u5ba2\u6237\u673a\u540d\u79f0\uff09<\/p>\n<p>      l         dstdomain : \u76ee\u6807\u540d\u79f0 \uff08\u5373\u670d\u52a1\u5668\u540d\u79f0\uff09<\/p>\n<p>      l         time : \u4e00\u5929\u4e2d\u7684\u65f6\u523b\u548c\u4e00\u5468\u5185\u7684\u4e00\u5929<\/p>\n<p>      l         url_regex : URL \u89c4\u5219\u8868\u8fbe\u5f0f\u5339\u914d<\/p>\n<p>      l         urlpath_regex: URL-path \u89c4\u5219\u8868\u8fbe\u5f0f\u5339\u914d\uff0c\u7565\u53bb\u534f\u8bae\u548c\u4e3b\u673a\u540d\uff0c\u53ea\u786e\u8ba4path\u5185\u5bb9<\/p>\n<p>      l         proxy_auth : \u901a\u8fc7\u5916\u90e8\u7a0b\u5e8f\u8fdb\u884c\u7528\u6237\u9a8c\u8bc1<\/p>\n<p>      l         maxconn : \u5355\u4e00 IP \u7684\u6700\u5927\u8fde\u63a5\u6570<\/p>\n<p>      \u6ce8\uff1a<\/p>\n<p>      1. acl_element_name \u53ef\u4ee5\u662f\u4efb\u4e00\u4e2a\u5728 ACL \u4e2d\u5b9a\u4e49\u7684\u540d\u79f0\u3002<\/p>\n<p>      2. \u4efb\u4f55\u4e24\u4e2a ACL \u5143\u7d20\u4e0d\u80fd\u7528\u76f8\u540c\u7684\u540d\u5b57\u3002<\/p>\n<p>      3. \u6bcf\u4e2a ACL \u7531\u5217\u8868\u503c\u7ec4\u6210\u3002\u5f53\u8fdb\u884c\u5339\u914d\u68c0\u6d4b\u7684\u65f6\u5019\uff0c\u591a\u4e2a\u503c\u7531\u903b\u8f91\u6216\u8fd0\u7b97\u8fde\u63a5\uff1b\u6362\u8a00\u4e4b\uff0c\u5373\u4efb\u4e00 ACL\u7684\u503c\u88ab\u5339\u914d\uff0c\u5219\u8fd9\u4e2a ACL\u5373\u88ab\u5339\u914d\u3002<\/p>\n<p>      4. \u5e76\u4e0d\u662f\u6240\u6709\u7684 ACL\u90fd\u80fd\u4f7f\u7528\u8bbf\u95ee\u5217\u8868\u4e2d\u7684\u5168\u90e8\u7c7b\u578b\u3002<\/p>\n<p>      5. \u4e0d\u540c\u7684 ACL\u5199\u5728\u4e0d\u540c\u884c\u4e2d\uff0cSquid \u5c06\u628a\u5b83\u4eec\u7ec4\u5408\u5728\u4e00\u4e2a\u5217\u8868\u4e2d\u3002<\/p>\n<p>      \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8bb8\u591a\u4e0d\u540c\u7684\u8bbf\u95ee\u5217\u8868\u3002\u6211\u4eec\u5e38\u7528\u7684\u662fhttp_access: \u5141\u8bb8 HTTP \u8bbf\u95ee\uff0c\u8fd9\u4e2a\u662f\u4e3b\u8981\u7684\u8bbf\u95ee\u63a7\u5236\u5217\u8868\u3002<\/p>\n<p>      \u8bbf\u95ee\u5217\u8868\u7684\u89c4\u5219\u7531\u4e00\u4e9b\u7c7b\u4f3c &#8216;allow&#8217; \u6216 &#8216;deny&#8217; \u7684\u5173\u952e\u5b57\u6784\u6210\uff0c\u7528\u4ee5\u5141\u8bb8\u6216\u62d2\u7edd\u5411\u7279\u5b9a\u6216\u4e00\u7ec4 ACL \u5143\u7d20\u63d0\u4f9b\u670d\u52a1\u3002<\/p>\n<p>      \u6ce8\uff1a<\/p>\n<p>      1. \u8fd9\u4e9b\u89c4\u5219\u6309\u7167\u5b83\u4eec\u7684\u6392\u5217\u987a\u5e8f\u8fdb\u884c\u5339\u914d\u68c0\u6d4b\uff0c\u4e00\u65e6\u68c0\u6d4b\u5230\u5339\u914d\u7684\u89c4\u5219\uff0c\u5339\u914d\u68c0\u6d4b\u5c31\u7acb\u5373\u7ed3\u675f\u3002<\/p>\n<p>      2. \u4e00\u4e2a\u8bbf\u95ee\u5217\u8868\u53ef\u4ee5\u53c8\u591a\u6761\u89c4\u5219\u7ec4\u6210\u3002<\/p>\n<p>      3. \u5982\u679c\u6ca1\u6709\u4efb\u4f55\u89c4\u5219\u4e0e\u8bbf\u95ee\u8bf7\u6c42\u5339\u914d\uff0c\u9ed8\u8ba4\u52a8\u4f5c\u5c06\u4e0e\u5217\u8868\u4e2d\u6700\u540e\u4e00\u6761\u89c4\u5219\u5bf9\u5e94\u3002<\/p>\n<p>      4. \u4e00\u4e2a\u8bbf\u95ee\u6761\u76ee\u4e2d\u7684\u6240\u6709\u5143\u7d20\u5c06\u7528\u903b\u8f91\u4e0e\u8fd0\u7b97\u8fde\u63a5\uff1a<\/p>\n<p>      http_access Action \u58f0\u660e1 AND \u58f0\u660e2 AND \u58f0\u660e OR.<\/p>\n<p>      http_access Action \u58f0\u660e3<\/p>\n<p>      \u591a\u4e2a http_access \u58f0\u660e\u95f4\u7528\u6216\u8fd0\u7b97\u8fde\u63a5\uff0c\u4f46\u6bcf\u4e2a\u8bbf\u95ee\u6761\u76ee\u7684\u5143\u7d20\u95f4\u7528\u4e0e\u8fd0\u7b97\u8fde\u63a5\u3002<\/p>\n<p>      5. \u8bf7\u8bb0\u4f4f\u5217\u8868\u4e2d\u7684\u89c4\u5219\u603b\u662f\u9075\u5faa\u7531\u4e0a\u800c\u4e0b\u7684\u987a\u5e8f\u3002<\/p>\n<p>      \u6211\u4eec\u5177\u4f53\u6765\u770b\u770b\u5982\u4f55\u8fd0\u7528acl\u548chttp_access\u3002\u9996\u5148\u628asquid.conf\u7684\u914d\u7f6e\u6539\u56de\u539f\u72b6\uff0c\u5373\u4fee\u6539http_access allow all\u4e3ahttp_access deny all\u3002\u4e0b\u9762\u7ed9\u51fa\u51e0\u79cd\u5e38\u7528\u8bbf\u95ee\u63a7\u5236\uff1a<\/p>\n<p>      \u6839\u636eIP\u9274\u6743<\/p>\n<p>      \u53ea\u6709\u5730\u5740\u4e3a192.168.100.10\u548c192.168.100.100\u7684\u7ec8\u7aef\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7406<\/p>\n<p>      \u5728squid.conf\u7684ACCESS CONTROL\u914d\u7f6e\u90e8\u5206\u6dfb\u52a0<\/p>\n<p>      acl authorizedip src 192.168.100.10<\/p>\n<p>      acl authorizedip src 192.168.100.100<\/p>\n<p>      \u7136\u540e\u5230http_access\u90e8\u5206<\/p>\n<p>      \u5728http_access deny all\u8fd9\u4e00\u884c\u524d\u9762\u6dfb\u52a0<\/p>\n<p>      http_access allow authorizedip<\/p>\n<p>      \u5982\u679c\u9700\u8981\u8bbe\u7f6e\u7684IP\u5730\u5740\u975e\u5e38\u591a\uff0c\u53c8\u4e0d\u8fde\u7eed\uff0c\u662f\u4e0d\u662f\u8981\u5199\u4e0a\u4e00\u5927\u5806\u7684acl xxx xxx x.x.x.x\uff1f\u6709\u4e00\u4e2a\u7b80\u5355\u7684\u65b9\u6cd5\uff0c\u628a\u8fd9\u4e9bIP\u5730\u5740\u5199\u5728\u4e00\u4e2a\u6587\u4ef6\u91cc\uff0c\u6bd4\u5982\/etc\/squid\/authorizedip.txt\uff0c\u6bcf\u884c\u4e00\u4e2a\u3002\u7136\u540e\u5728squid.conf\u91cc\u8fd9\u6837\u5199<\/p>\n<p>      acl authorizedip src &#8220;\/etc\/squid\/authorizedip.txt&#8221;<\/p>\n<p>      \u6839\u636e\u65f6\u95f4\u63a7\u5236<\/p>\n<p>      \u5173\u4e8e\u65f6\u95f4\u6bb5\u7684\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u53c2\u89c1squid.conf\u4e2d\u7684\u8bf4\u660e\uff0c\u5177\u4f53\u662fS &#8211; Sunday, M &#8211; Monday, T &#8211; Tuesday, W &#8211; Wednesday, H &#8211; Thursday, F &#8211; Friday A &#8211; Saturday\uff0c\u5982\u679c\u4e03\u5929\u90fd\u5141\u8bb8\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u5199\u3002\u65f6\u95f4\u683c\u5f0f\u662fH1:M1-H2:M2\uff0c\u8981\u6c42\u662f\u524d\u9762\u7684\u8981\u5c0f\u4e8e\u540e\u9762\u7684\u3002<\/p>\n<p>      # \u5b9a\u4e49\u4e00\u4e2a\u8bbf\u95ee\u65f6\u95f4\u6bb5\uff1a\u6bcf\u5468\u661f\u671f\u4e00\u5230\u661f\u671f\u4e94\u7684\u4e0a\u5348\u516b\u70b9\u5230\u4e0b\u5348\u4e94\u70b9\uff0c\u5141\u8bb8alloweduser\u7528\u6237\u5728\u8fd9\u4e2a\u65f6\u95f4\u6bb5\u5185\u4e0a\u7f51<\/p>\n<p>      acl accept_time time MTWHF 8:00-17:00<\/p>\n<p>      http_access allow alloweduser accept_time<\/p>\n<p>      http_access deny alloweduser<\/p>\n<p>      \u8bbf\u95ee\u7279\u5b9aURL\u5730\u5740<\/p>\n<p>      \u867d\u7136\u6211\u4eec\u4e0d\u5e0c\u671b\u6240\u6709\u7684\u4eba\u90fd\u4f7f\u7528\u4ee3\u7406\u81ea\u7531\u7684\u8bbf\u95eeInternet\uff0c\u4f46\u6709\u51e0\u4e2a\u7f51\u7ad9\u662f\u53ef\u4ee5\u8ba9\u5185\u90e8\u7ec8\u7aef\u90fd\u80fd\u8bbf\u95ee\u7684\u3002\u5728squid.conf\u91cc\u6dfb\u52a0\u8bbf\u95ee\u63a7\u5236\uff1a<\/p>\n<p>      acl alloweddomain dstdomain .linuxforum.net .linuxaid.com.cn<\/p>\n<p>      http_access allow alloweddomain<\/p>\n<p>      \u540c\u6837\u7684\uff0c\u5982\u679c\u53c2\u6570\u5f88\u591a\u7684\u60c5\u51b5\uff0c\u4e5f\u53ef\u4ee5\u628a\u8fd9\u4e9b\u5141\u8bb8\u7684\u5730\u5740\u540d\u5199\u5230\u4e00\u4e2a\u6587\u672c\u91cc\uff1a<\/p>\n<p>      acl alloweddomain dstdomain &#8220;\/etc\/squid\/alloweddomain.txt&#8221;<\/p>\n<p>      alloweddomain.txt\u91cc\u662f\u5141\u8bb8\u8bbf\u95ee\u7ad9\u70b9\u7684\u5217\u8868\uff0c\u6bcf\u884c\u4e00\u4e2a\u3002<\/p>\n<p>      \u6839\u636e\u5173\u952e\u5b57\u8fc7\u6ee4\u7f51\u5740<\/p>\n<p>      \u6709\u4e9b\u7f51\u7ad9\uff08\u8272\u60c5\u7f51\u7ad9\uff0c\u5e7f\u544a\u7f51\u7ad9\uff09\u5f88\u4ee4\u4eba\u8ba8\u538c\uff0c\u901a\u8fc7\u8bbe\u7f6eacl\u53ef\u4ee5\u5f88\u5bb9\u6613\u5c4f\u853d\u6389\u8fd9\u4e9b\u7ad9\u70b9\uff1a<\/p>\n<p>      acl denyurl url_regex sex boylink xxx city69 asiaadult sehu<\/p>\n<p>      http_access deny denyurl<\/p>\n<p>      \u8fd9\u4e2a\u8bbe\u7f6e\u5c06\u8fc7\u6ee4\u5e26\u6709sex boylink xxx city69 asiaadult sehu\u8fd9\u4e9b\u5173\u952e\u5b57\u7684URL\u5730\u5740\u3002<\/p>\n<p>      \u548c\u524d\u9762\u4e00\u6837\uff0c\u4e5f\u53ef\u4ee5\u628a\u8fd9\u4e9b\u5173\u952e\u5b57\u5199\u5230\u4e00\u4e2a\u6587\u672c\u91cc<\/p>\n<p>      acl denyedurl url_regex &#8220;\/etc\/squid\/sex.txt&#8221;<\/p>\n<p>      http_access deny denyurl<\/p>\n<p>      \u57fa\u4e8e\u7528\u6237\u7684\u8ba4\u8bc1<\/p>\n<p>      Squid\u672c\u8eab\u5e76\u4e0d\u652f\u6301\u7528\u6237\u9a8c\u8bc1\uff0c\u5b83\u662f\u901a\u8fc7\u5916\u90e8\u7a0b\u5e8f\u63d0\u4f9b\u7528\u6237\u9a8c\u8bc1\u529f\u80fd\uff0c\u7528\u6237\u901a\u8fc7squid\u8bbf\u95ee\u524d\u9700\u8981\u8f93\u5165\u6709\u6548\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002\u53ef\u4ee5\u7528 proxy_auth  ACL \u548c authenticate_program \u6765\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\uff0c\u5728\u5141\u8bb8\u8bbf\u95ee\u524d\u5f3a\u5236\u8fdb\u884c\u7528\u6237\u540d\u548c\u5bc6\u7801\u7684\u6838\u67e5\u3002\u4e0b\u9762\u5217\u51fa\u4e00\u4e9b Squid \u80fd\u7528\u5230\u7684\u9a8c\u8bc1\u7a0b\u5e8f\uff1a<\/p>\n<p>      NCSA : \u4f7f\u7528 NCSA \u98ce\u683c\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u6863<\/p>\n<p>      LDAP : \u4f7f\u7528 Linux Lightweight \u76ee\u5f55\u8bbf\u95ee\u534f\u8bae\uff08Linux Lightweight Directory Access Protocol\uff09<\/p>\n<p>      SMB : \u4f7f\u7528 SMB \u534f\u8bae\u7684\u670d\u52a1\uff0c\u5982 SAMBA \u6216 Windows NT<\/p>\n<p>      MSNT : \u4f7f\u7528 Windows NT \u7684\u57df\u9a8c\u8bc1<\/p>\n<p>      PAM : \u4f7f\u7528 Linux \u7684\u53ef\u88c5\u8f7d\u9a8c\u8bc1\u6a21\u5757<\/p>\n<p>      getpwam : \u4f7f\u7528 Linux \u5bc6\u7801\u6863<\/p>\n<p>      \u4f7f\u7528\u9a8c\u8bc1\u529f\u80fd\u5fc5\u987b\u7528authenticate_program \u9009\u9879\u6307\u5b9a\u4f7f\u4ec0\u4e48\u9a8c\u8bc1\u7a0b\u5e8f\uff0c\u5e76\u4e14\u8bf7\u786e\u8ba4\u9009\u5b9a\u7684\u9a8c\u8bc1\u7a0b\u5e8f\u5df2\u5b89\u88c5\u5e76\u80fd\u5f88\u597d\u7684\u5de5\u4f5c\u3002\u9ed8\u8ba4\u7684\uff0c\u8fd9\u4e9b\u9a8c\u8bc1\u7a0b\u5e8f\u653e\u5728\/usr\/lib\/squid\/\u76ee\u5f55\u4e0b\u3002<\/p>\n<p>      \u4ee5NCSA\u8ba4\u8bc1\u4e3a\u4f8b\uff0c\u4fee\u6539 squid.conf \u6587\u4ef6\u9009\u5b9a\u9a8c\u8bc1\u7a0b\u5e8f\uff1a<\/p>\n<p>      authenticate_program \/usr\/lib\/squid\/ncsa_auth \/etc\/squid\/passwd <\/p>\n<p>      acl alloweduser proxy_auth pangty<\/p>\n<p>      http_access allow alloweduser<\/p>\n<p>      \u5176\u4e2d\/etc\/squid\/passwd\u662f\u7528\u6237\u548c\u5bc6\u7801\u5217\u8868\uff0c\u8fd9\u4e2a\u6587\u4ef6\u53ef\u4ee5\u7528apache\u8f6f\u4ef6\u5305\u5e26\u7684htpasswd\u6765\u4ea7\u751f\uff0c\u5b83\u7684\u5185\u5bb9\u53ef\u80fd\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p>      pangty:wCQhCeZOOF3vk<\/p>\n<p>      pangty\u662f\u7528\u6237\u540d\uff0c\u201c:\u201d\u53f7\u540e\u9762\u7684\u662f\u8be5\u7528\u6237\u7684\u5bc6\u7801\u3002<\/p>\n<p>      \u6ce8\u610f\uff1a\u4fee\u6539\u4e86squid.conf\u914d\u7f6e\u540e\uff0c\u9700\u8981\u91cd\u65b0\u542f\u52a8squid\u6216\u8005\u544a\u8bc9squid\u91cd\u65b0\u88c5\u5165\u914d\u7f6e\u6587\u4ef6\u624d\u80fd\u8d77\u4f5c\u7528\u3002\u8fd9\u6837\u6267\u884c\uff1a<\/p>\n<p>      \u91cd\u8d77squid\uff1a<\/p>\n<p>      [root@rh73 ~]# \/etc\/rc.d\/init.d\/squid restart<\/p>\n<p>      \u4e0d\u91cd\u8d77\uff0c\u53ea\u88c5\u5165\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<p>      [root@rh73 ~]# \/etc\/rc.d\/init.d\/squid reload<\/p>\n<p>      \u4ee5\u4e0a\u662fsquid\u7684\u5e38\u7528\u7684\u914d\u7f6e\u9009\u9879\uff0c\u8fd9\u5bf9\u4e8e\u4e00\u822c\u7684\u5e94\u7528\u6765\u8bf4\u5df2\u7ecf\u8db3\u591f\u4e86\uff0c\u5982\u679c\u4f60\u9700\u8981\u66f4\u591a\u7684\u7279\u6027\u652f\u6301\uff0c\u8bf7\u9605\u8bfb\u4e0b\u9762\u7684\u5185\u5bb9\u3002<\/p>\n<p>      \u00a7\u00a7\u3000\u9700\u8981\u66f4\u591a\u7684\u529f\u80fd<\/p>\n<p>      \u663e\u793a\u4e2d\u6587\u9519\u8bef\u63d0\u793a\u4fe1\u606f<\/p>\n<p>      \u9ed8\u8ba4\u7684\uff0csquid\u5728\u53d1\u751f\u9519\u8bef\u65f6\u663e\u793a\u7684\u662f\u82f1\u6587\u63d0\u793a\u4fe1\u606f\uff0csquid\u7684\u63d0\u793a\u4fe1\u606f\u5df2\u7ecf\u88ab\u7ffb\u8bd1\u6210\u5f88\u591a\u8bed\u8a00\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u8ba9\u4ed6\u663e\u793a\u4e2d\u6587\u4fe1\u606f\uff1a<\/p>\n<p>      [root@rh73 ~]# cd \/etc\/squid\/<\/p>\n<p>      [root@rh73 ~]# rm -f errors<\/p>\n<p>      [root@rh73 \/etc\/squid]# ln -s \/usr\/lib\/squid\/errors\/Simplify_Chinese\/ errors<\/p>\n<p>      \/usr\/lib\/squid\/errors\u4e0b\u9762\u6709squid\u7684\u5404\u79cd\u8bed\u8a00\u7248\u672c\u7684\u63d0\u793a\u4fe1\u606f\uff0c\u6309\u76ee\u5f55\u5b58\u653e\u5728\u4e0d\u540c\u7684\u5b50\u76ee\u5f55\u4e0b\u9762\u3002<\/p>\n<p>      \u652f\u6301\u57fa\u4e8eMAC\u7684\u63a7\u5236\u4ee5\u53ca\u8bbf\u95ee\u5e26\u6709\u4e0b\u5212\u7ebf\u7684URL<\/p>\n<p>      \u7531\u4e8e\u8ba1\u7b97\u673a\u7684IP\u5730\u5740\u662f\u968f\u65f6\u53ef\u4ee5\u66f4\u6539\u7684\uff0c\u6240\u4ee5\u5373\u4fbf\u4f60\u8bbe\u7f6e\u4e86ACL\u9650\u5236\u53ea\u6709\u67d0\u4e9bIP\u7684\u8ba1\u7b97\u673a\u53ef\u4ee5\u8bbf\u95eeInternet\uff0c\u5176\u5b83\u4eba\u4ecd\u7136\u53ef\u4ee5\u5728\u8be5\u8ba1\u7b97\u673a\u5173\u673a\u7684\u60c5\u51b5\u4e0b\uff0c\u4fee\u6539\u6210\u8fd9\u4e9b\u5141\u8bb8\u4e0a\u7f51\u7684IP\u5730\u5740\u540e\u8bbf\u95eeInternet\u3002\u53e6\u5916\uff0c\u524d\u9762\u6211\u4eec\u662f\u4f7f\u7528DHCP\u6765\u7ba1\u7406\u5185\u90e8\u7f51\u7edc\u4e0a\u7684\u8ba1\u7b97\u673a\u7684IP\u5730\u5740\uff0c\u6bcf\u53f0\u8ba1\u7b97\u673a\u6bcf\u6b21\u83b7\u5f97\u7684IP\u5730\u5740\u53ef\u80fd\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u6240\u4ee5\uff0c\u5355\u7eaf\u7684\u901a\u8fc7IP\u5730\u5740\u6765\u63a7\u5236\u4e0a\u7f51\u6743\u9650\u5e76\u4e0d\u9002\u5408\u6240\u6709\u7684\u573a\u5408\uff0c\u800cMAC\u5730\u5740\u76f8\u5bf9\u662f\u7a33\u5b9a\u7684\uff0c\u4e00\u822c\u7f51\u5361\u7684MAC\u5730\u5740\u4e0d\u80fd\u591f\u66f4\u6539\uff0c\u6240\u4ee5\u57fa\u4e8eMAC\u5730\u5740\u7684\u7528\u6237\u63a7\u5236\u975e\u5e38\u9002\u5408\u89e3\u51b3\u8fd9\u4e24\u79cd\u60c5\u51b5\u5e26\u6765\u7684\u95ee\u9898\u3002<\/p>\n<p>      \u53e6\u5916\uff0c\u6211\u4eec\u8bbf\u95eeInternet\u65f6\uff0c\u6709\u65f6\u5019\u4f1a\u9047\u5230\u8fd9\u6837\u7684\u7f51\u7ad9\u5730\u5740\uff1ahttp:\/\/www.hello_world.com\uff0c\u5728\u7f51\u7ad9\u7684URL\u5730\u5740\u91cc\u9762\u6709\u4e0b\u5212\u7ebf\uff0c\u8fd9\u65f6Red Hat Linux\u81ea\u5e26\u7684squid\u8f6f\u4ef6\u5305\u53ef\u80fd\u4f1a\u62a5\u544a\u65e0\u6cd5\u8bbf\u95ee\u8be5\u7f51\u7ad9\u3002<\/p>\n<p>      \u8fd9\u4e9b\u529f\u80fd\u9700\u8981\u91cd\u65b0\u7f16\u8bd1squid\u6e90\u4ee3\u7801\u589e\u52a0\u76f8\u5e94\u7684\u7f16\u8bd1\u9009\u9879\u6765\u5b9e\u73b0\u3002\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u770b\u4e00\u4e0b\u5982\u4f55\u4f7f\u7528rpm\u91cd\u65b0\u7f16\u8bd1\u8f6f\u4ef6\u5305\u6e90\u4ee3\u7801\u83b7\u5f97\u5fc5\u8981\u7684\u529f\u80fd\u3002<\/p>\n<p>      \u5f53\u6587\u7ae0\u5199\u5230\u8fd9\u91cc\u7684\u65f6\u5019\uff0cRed Hat Linux\u7f51\u7ad9\u53d1\u5e03\u4e86squid\u7684\u5347\u7ea7\u8f6f\u4ef6\u5305\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u7f51\u4e0a\u83b7\u5f97\u5b83\u7684\u6700\u65b0\u6e90\u4ee3\u7801rpm\u5305\uff1a<\/p>\n<p>      ftp:\/\/updates.redhat.com\/7.2\/en\/os\/SRPMS\/squid-2.4.STABLE6-6.7.3.src.rpm<\/p>\n<p>      \u5728\u5f00\u59cb\u7f16\u8bd1\u524d\uff0c\u6709\u4e00\u4e9b\u8f6f\u4ef6\u5305\u662f\u9700\u8981\u9996\u5148\u5b89\u88c5\uff0c\u8fd9\u53ef\u80fd\u5305\u62ecrpm-build\u3001sgml-tools\uff0c\u524d\u8005\u5728Red Hat Linux\u7684\u5149\u76d8\u4e0a\u53ef\u4ee5\u627e\u5230\uff0c\u540e\u8005\u53ef\u4ee5\u4ece\u8fd9\u91cc\u4e0b\u8f7d\uff1a<\/p>\n<p>      ftp:\/\/ftp.freesoft.cei.gov.cn\/.mirror2\/ftp.redhat.com\/redhat-7.2\/i386\/RedHat\/RPMS\/sgml-tools-1.0.9-12.i386.rpm<\/p>\n<p>      \u5b89\u88c5squid\u7684\u6e90\u4ee3\u7801\u5305<\/p>\n<p>      [root@rh73 ~]# rpm -ivh squid-2.4.STABLE6-6.7.3.src.rpm<\/p>\n<p>      \u5b89\u88c5\u540e\u7684\u6e90\u4ee3\u7801\u5305\u5728\/usr\/src\/redhat\/SOURCES\u76ee\u5f55\u4e0b\uff0c\u6211\u4eec\u5173\u5fc3\u7684\u662f\u53e6\u5916\u4e00\u4e2a\u6587\u4ef6\/usr\/src\/redhat\/SPECS\/squid.spec\uff0c\u8fd9\u91cc\u9762\u6709squid\u7684\u76f8\u5173\u7f16\u8bd1\u9009\u9879\uff0c\u4fee\u6539\u8be5\u6587\u4ef6%configure\u90e8\u5206\u5982\u4e0b\uff1a<\/p>\n<p>      %configure \\<\/p>\n<p>   &#8211;exec_prefix=\/usr &#8211;bindir=\/usr\/sbin &#8211;libexecdir=\/usr\/lib\/squid \\<\/p>\n<p>   &#8211;localstatedir=\/var &#8211;sysconfdir=\/etc\/squid \\<\/p>\n<p>   &#8211;enable-poll &#8211;enable-snmp &#8211;enable-removal-policies=&#8221;heap,lru&#8221; \\<\/p>\n<p>   &#8211;enable-storeio=&#8221;aufs,coss,diskd,ufs&#8221; \\<\/p>\n<p>   &#8211;enable-delay-pools &#8211;enable-linux-netfilter \\<\/p>\n<p>   &#8211;with-pthreads \\<\/p>\n<p>   &#8211;enable-underscores \\<\/p>\n<p>   &#8211;enable-arp-acl \\<\/p>\n<p>   &#8211;enable-err-language=Simplify_Chinese \\<\/p>\n<p>   &#8211;enable-auth-modules=&#8221;LDAP,NCSA,PAM,SMB,MSNT&#8221;  # &#8211;enable-icmp<\/p>\n<p>      &#8211;enable-underscores\u662f\u589e\u52a0\u5bf9\u4e0b\u5212\u7ebf\u7f51\u5740\u7684\u652f\u6301\uff0c&#8211;enable-arp-acl\u662f\u589e\u52a0\u652f\u6301MAC\u5730\u5740\u65b9\u5f0f\u7684\u9274\u6743\u3002<\/p>\n<p>      \u5f00\u59cb\u7f16\u8bd1\u4ea7\u751f\u65b0\u7684RPM\u5305\uff1a<\/p>\n<p>      [root@rh73 ~]# rpm -ba squid.spec<\/p>\n<p>      \u8fd9\u6761\u547d\u4ee4\u5c06\u6839\u636esquid.spec\u7684\u914d\u7f6e\u91cd\u65b0\u7f16\u8bd1\u751f\u6210\u65b0\u7684rpm\u5305\u3002\u7f16\u8bd1\u8fc7\u7a0b\u89c6\u673a\u5668\u6027\u80fd\u7684\u597d\u574f\u800c\u5b9a\uff0c\u5927\u6982\u9700\u8981\u51e0\u5206\u949f\u5230\u51e0\u5341\u5206\u949f\u4e0d\u7b49\uff0c\u5982\u679c\u6ca1\u6709\u4ec0\u4e48\u9519\u8bef\uff0c\u6700\u540e\u4ea7\u751f\u7684\u65b0\u7684rpm\u5305\u5728\/usr\/src\/redhat\/RPMS\/i386\/\u76ee\u5f55\u4e0b\uff1asquid-2.4.STABLE6-6.7.3.i386.rpm<\/p>\n<p>      \u5b89\u88c5\u65b0\u7684rpm\u5305\uff1a<\/p>\n<p>      [root@rh73 ~]# rpm -Uvh \/usr\/src\/redhat\/RPMS\/i386\/squid-2.4.STABLE6-6.7.3.i386.rpm<\/p>\n<p>      \u6ce8\u610f\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86-U\u53c2\u6570\uff0c\u662f\u56e0\u4e3a\u6211\u4eec\u524d\u9762\u5df2\u7ecf\u5b89\u88c5\u8fc7squid\u7684\u4e00\u4e2a\u8f83\u65e7\u7684\u7248\u672c\uff0c-U\u53c2\u6570\u6307\u51fa\u8fd9\u4e2a\u64cd\u4f5c\u662f\u5bf9\u539f\u6709\u7248\u672c\u8f6f\u4ef6\u5305\u7684\u5347\u7ea7\u3002\u73b0\u5728\u4f60\u7684squid\u5c31\u53ef\u4ee5\u652f\u6301MAC\u5730\u5740\u9274\u6743\u548c\u5e26\u4e0b\u5212\u7ebf\u7684URL\u5730\u5740\u4e86\u3002 8)<\/p>\n<p>      \u914d\u7f6esquid.conf\u6765\u652f\u6301MAC\u5730\u5740\u9274\u6743\uff0c\u5728squid.conf\u91cc\u52a0\u5165\u8fd9\u6837\u7684\u5185\u5bb9\uff1a<\/p>\n<p>      acl allowedmac arp 00:10:DC:8F:5B:FF<\/p>\n<p>      http_access allow allowedmac<\/p>\n<p>      \u4e0a\u9762\u53ea\u662f\u5e38\u7528\u7684\u51e0\u79cdACL\u8bbe\u7f6e\u7684\u793a\u4f8b\uff0c\u5173\u4e8eACL\u53ef\u4ee5\u8bbf\u95eesquid\u4e3b\u9875\u4e0aFAQ\u6587\u6863\u7684Access Controls\u90e8\u5206\u83b7\u5f97\u66f4\u591a\u7684\u4fe1\u606f\uff1a<\/p>\n<p>      http:\/\/www.squid-cache.org\/Doc\/FAQ\/FAQ-10.html<\/p>\n<p>      \u00a7\u00a7\u3000\u914d\u7f6e\u900f\u660e\u4ee3\u7406<\/p>\n<p>      \u900f\u660e\u4ee3\u7406\u662fNAT\u548c\u4ee3\u7406\u7684\u5b8c\u7f8e\u7ed3\u5408\uff0c\u4e4b\u6240\u4ee5\u79f0\u4e3a\u900f\u660e\uff0c\u662f\u56e0\u4e3a\u5728\u8fd9\u79cd\u5de5\u4f5c\u65b9\u5f0f\u4e0b\u4f60\u611f\u89c9\u4e0d\u5230\u4ee3\u7406\u7684\u5b58\u5728\uff0c\u548c\u5355\u7eaf\u4f7f\u7528NAT\u4e00\u6837\uff0c\u5bf9\u4e0a\u7f51\u7684\u5ba2\u6237\u7aef\u6ca1\u6709\u4efb\u4f55\u7279\u6b8a\u7684\u8bbe\u7f6e\u3002Squid\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u652f\u6301\u900f\u660e\u4ee3\u7406\u3002<\/p>\n<p>      \u5f88\u591a\u6587\u7ae0\u8bb2\u5230\u5171\u4eab\u4e0a\u7f51\u5c31\u4f1a\u8bb2\u6709\u5173\u900f\u660e\u4ee3\u7406\uff08iptables + squid\u6216ipchains + squid\uff09\u7684\u5185\u5bb9\uff0c\u6211\u4e2a\u4eba\u8ba4\u4e3a\u5bf9\u4e8e\u89c4\u6a21\u4e0d\u5927\u7684\u7f51\u7edc\uff0c\u53c8\u6ca1\u6709\u5185\u5bb9\u8fc7\u6ee4\u7b49\u529f\u80fd\u7684\u8981\u6c42\uff0c\u4f7f\u7528squid\u662f\u6ca1\u6709\u5fc5\u8981\u7684\uff0c\u5355\u7eaf\u7684\u4f7f\u7528NAT\u65b9\u5f0f\u5c31\u8db3\u591f\u4e86\uff0c\u5e76\u4e14\u8fd9\u6837\u5bf9\u8fd0\u884cNAT\u7684\u670d\u52a1\u5668\u7684\u8981\u6c42\u5c31\u66f4\u52a0\u4f4e\uff0c\u6bd4\u5982\u4f7f\u7528\u4e00\u53f0486 + 4M\u5185\u5b58\u7684\u673a\u5668\uff0c\u5982\u679c\u4f7f\u7528\u90a3\u4e9b\u7ecf\u8fc7\u7279\u6b8a\u5b9a\u5236\u7684Linux\u7cfb\u7edf\uff0c\u751a\u81f3\u8fde\u786c\u76d8\u90fd\u4e0d\u9700\u8981\uff0c\u53ea\u8981\u4e00\u5f20\u8f6f\u76d8\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>      \u5982\u679c\u662f\u6e90\u4ee3\u7801\u65b9\u5f0f\u7f16\u8bd1\u5b89\u88c5\u7684squid\uff0c\u8bf7\u5728\u7f16\u8bd1\u9009\u9879\u91cc\u6307\u660e&#8211;enable-linux-netfilter\u9009\u9879\u3002Red Hat Linux\u81ea\u5e26\u7684squid\u652f\u6301\u900f\u660e\u4ee3\u7406\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\/etc\/squid\/squid.conf\u6587\u4ef6\uff0c\u8bbe\u7f6e\u5fc5\u8981\u7684\u53c2\u6570\uff1a<\/p>\n<p>      httpd_accel_host virtual<\/p>\n<p>      httpd_accel_port 80<\/p>\n<p>      httpd_accel_with_proxy on<\/p>\n<p>      httpd_accel_uses_host_header on<\/p>\n<p>      \u8fd0\u884c\/etc\/rc.d\/init.d\/squid reload\u4f7f\u8bbe\u7f6e\u751f\u6548\uff0c\u7136\u540e\u4fee\u6539fw.sh\u811a\u672c\uff0c\u5728\u6700\u540e\u6dfb\u52a0\u8fd9\u6837\u4e00\u884c\uff1a<\/p>\n<p>      iptables -A PREROUTING -t nat -i eth1 -p tcp &#8211;dport 80 -j REDIRECT &#8211;to-port 3128<\/p>\n<p>      \u8fd9\u5c06\u628a\u6240\u6709\u5c40\u57df\u7f51\u7528\u6237\u901a\u8fc7Linux\u63a5\u5165\u670d\u52a1\u5668\u8bbf\u95eewww\u670d\u52a1\u7684\u8bbf\u95ee\u8bf7\u6c42\u91cd\u5b9a\u5411\u5230\u5de5\u4f5c\u57283128\u7aef\u53e3\u7684squid\u5904\u7406\u3002\u8fd0\u884cfw.sh\u811a\u672c\uff0c\u4f7f\u8bbe\u7f6e\u751f\u6548\u3002\u5c31\u8fd9\u4e48\u7b80\u5355\uff01<\/p>\n<p>      \u4f60\u53ef\u80fd\u8fd8\u8bb0\u5f97fw.sh\u91cc\u9762\u7684\u5173\u4e8eNAT\u7684\u89c4\u5219\uff1a<\/p>\n<p>      iptables -A POSTROUTING -t nat -s 192.168.100.0\/24 -o eth0 -j SNAT &#8211;to-source 61.156.35.114<\/p>\n<p>      \u7531\u4e8ePREROUTING\u89c4\u5219\u603b\u5728POSTROUTING\u89c4\u5219\u4e4b\u524d\u5e94\u7528\uff0c\u6240\u4ee5\u4e0d\u7528\u62c5\u5fc3squid\u88abNAT\u89c4\u5219\u5c4f\u853d\u6389\u3002<\/p>\n<p>      \u6ce8\u610f\uff1a\u4f7f\u7528\u900f\u660e\u4ee3\u7406\u65f6\uff0c\u65e0\u6cd5\u540c\u65f6\u4f7f\u7528squid\u57fa\u4e8e\u7528\u6237\u5e10\u53f7\u7684\u9a8c\u8bc1\u529f\u80fd\uff01<\/p>\n<p>      \u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u900f\u660e\u4ee3\u7406\u7684\u8d44\u6599\uff0c\u8bf7\u8bbf\u95eeTLDP\uff08The Linux Documentation Project\uff09\u4e0a\u5173\u4e8e\u900f\u660e\u4ee3\u7406\u7684HOWTO\u6587\u6863\uff1a<\/p>\n<p>      http:\/\/www.tldp.org\/HOWTO\/mini\/TransparentProxy.html<\/p>\n<p>      \u00a7\u00a7\u3000\u4e00\u4e2asquid.conf\u7684\u914d\u7f6e\u5b9e\u4f8b<\/p>\n<p>      \u73b0\u5728\u7ed9\u51fa\u4e00\u4e2a\u652f\u6301\u900f\u660e\u4ee3\u7406\u5e76\u4f7f\u7528MAC\u5730\u5740\u63a7\u5236\u7528\u6237\u4e0a\u7f51\u6743\u9650\u7684squid\u914d\u7f6e\u6587\u4ef6\uff0c\u8be5\u914d\u7f6e\u8fd8\u652f\u6301\u7279\u5b9a\u7f51\u7ad9\uff08\u5982\u8272\u60c5\u7f51\u7ad9\uff09\u7684\u8fc7\u6ee4\u529f\u80fd\uff1a<\/p>\n<p>      #\u5b9a\u4e49\u670d\u52a1\u5668\u5730\u5740\u548c\u7aef\u53e3<\/p>\n<p>      http_port 192.168.100.254:3128<\/p>\n<p>      #\u5b9a\u4e49\u670d\u52a1\u5668\u540d\u5b57<\/p>\n<p>      visible_hostname 192.168.100.254<\/p>\n<p>      #\u5b9a\u4e49\u7ba1\u7406\u5458\u90ae\u4ef6\u5730\u5740<\/p>\n<p>      cache_mgr pangty@usa.net<\/p>\n<p>      #\u5b9a\u4e49\u7f13\u5b58\u5185\u5b58\u7a7a\u95f4\u548c\u7f13\u5b58\u76ee\u5f55<\/p>\n<p>      cache_mem 16 MB<\/p>\n<p>      cache_dir ufs \/var\/spool\/squid 100 16 256<\/p>\n<p>      #\u652f\u6301\u900f\u660e\u4ee3\u7406\n      <\/p>\n<p>2.6\u4ee5\u4e0a\u7248\u672c\u53ea\u9700\u8981\u5728http_port \u540e\u52a0\u53c2\u6570\u5c31\u53ef\n      <\/p>\n<p>http_port 3128 transparent\n      <\/p>\n<p>2.5\u4ee5\u4e0b\u7248\u672c\u5982\u4e0b\u8bbe\u7f6e<\/p>\n<p>      httpd_accel_host virtual<\/p>\n<p>      httpd_accel_port 80<\/p>\n<p>      httpd_accel_with_proxy on<\/p>\n<p>      httpd_accel_uses_host_header on<\/p>\n<p>      #\u5b9a\u4e49acl<\/p>\n<p>      #sexurl.txt\u5217\u51fa\u8981\u8fc7\u6ee4\u8272\u60c5\u7f51\u7ad9\u5730\u5740\u7684\u5173\u952e\u5b57\uff0c\u6bcf\u4e2a\u5173\u952e\u5b57\u5360\u4e00\u884c\uff0c\u5982xchina <\/p>\n<p>      #maclist.txt\u5217\u51fa\u5141\u8bb8\u4e0a\u7f51\u7684\u4e3b\u673a\u7684MAC\u5730\u5740\uff0c\u6bcf\u4e2a\u5730\u5740\u5360\u4e00\u884c\uff0c\u598200:50:56:C0:00:08<\/p>\n<p>      acl all src 0.0.0.0\/0.0.0.0<\/p>\n<p>      acl sexurl url_regex &#8220;\/etc\/squid\/sexurl.txt&#8221;<\/p>\n<p>      acl allowedmac arp &#8220;\/etc\/squid\/maclist.txt&#8221;<\/p>\n<p>      #\u5b9a\u4e49\u8bbf\u95ee\u7b56\u7565<\/p>\n<p>      http_access deny sexurl<\/p>\n<p>      http_access allow allowedmac<\/p>\n<p>      http_access deny all<\/p>\n<p>      #\u652f\u6301https\u4ee3\u7406(\u6240\u6709ssl\u8bbe\u7f6e\u90fd\u9700\u8981\u5728\u7f16\u8bd1\u7684\u65f6\u5019\u6709<font SIZE=\"2\">&#8211;enable-ssl<\/font>)<\/p>\n<p>      https_port 443 cert=\/etc\/squid\/cert.pem key=\/etc\/squid\/key.pem<\/p>\n<p>      \u8bc1\u4e66\u7531ssl\u751f\u6210<\/p>\n<p>      openssl req -new -keyout \/etc\/squid\/key.pem -nodes -x509 -days 365 -out<br \/>\n      \/etc\/squid\/cert.pem\n      <\/p>\n<p>\n      #\u8fd0\u884c\u6743\u9650\u4e0e\u76ee\u5f55\u6743\u9650\n      <\/p>\n<p>squid\u4e3a\u4e86\u5b89\u5168\u9ed8\u8ba4\u662f\u4ee5nobody\u8fd0\u884c\u7684\uff0c\u53ef\u4ee5\u4fee\u6539\u4e0b\u9762\u4e8c\u4e2a\u9009\u9879\u6307\u5b9a\u7528\u6237\n      <\/p>\n<p>cache_effective_user nobody<\/p>\n<p>      cache_effective_group\n      <\/p>\n<p>\u5982\u679c\u4e0d\u662f\u7528rpm\u5b89\u88c5\u7684squid\uff0c\u901a\u5e38LOG\u76ee\u5f55\u7684\u6743\u9650\u662f\u4e0d\u4f1a\u8bbe\u7f6e\u597d\u7684\uff0c\u8fd9\u6837squid\u5c31\u65e0\u6cd5\u5199cache\u4e0elogs\u9700\u8981\u6539\u4e00\u4e0b\u76ee\u5f55\u6240\u6709\u8005\n      <\/p>\n<p>chown -R nobody:nobody \/usr\/local\/squid\/var\n      <\/p>\n<p>#\u4fee\u6539file descriptors\u6570\u91cf\n      <\/p>\n<p>\u5927\u591a\u6570Linux\u9ed8\u8ba4\u5b89\u88c5\u7684squid\u662f\u6709\u9650\u5236\u7684\uff0c\u5982\u679c\u7528\u6237\u8fc7\u591a\u7684\u60c5\u51b5\u4e0b\u4f1a\u51fa\u95ee\u9898\uff1a<br \/>\n      \u542f\u52a8squid\u540e,\u67e5\u770bcache.log\u6587\u4ef6:<br \/>\n      With 1024 file descriptors available<br \/> <br \/>\n      \u544a\u8bc9\u4f60\u6b64squid\u8fdb\u7a0b\u53ef\u4f7f\u7528\u7684file descriptors\u6570\u91cf,\u50cf\u8fd9\u4e2a\u624d1024,\u5f88\u5bb9\u6613\u8ba9squid\u62b1\u6028:<br \/> <br \/>\n      WARNING! Your cache is running out of filedescriptors<\/p>\n<p>      \u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b:<br \/>\n      1 \u786e\u4fddLinux\u7cfb\u7edf\u6574\u4f53\u80fd\u5bb9\u7eb3\u7684file descriptors\u8db3\u591f\u591a: <br \/> <br \/>\n      sysctl -w fs.file-max=&#8221;410348&#8243;<br \/> <br \/>\n      2 \u4fdd\u8bc1shell\u80fd\u63d0\u4f9b\u7ed9squid\u8db3\u591f\u591a\u7684file descriptors: <br \/> <br \/>\n      ulimit -HSn 32768<br \/> <br \/>\n      \u6216<br \/>\n      vi \/etc\/security\/limits.conf<br \/> <br \/>\n      \u52a0\u5165<br \/>\n      *\tsoft\tnofile\t32768<br \/> <br \/>\n      *\thard\tnofile\t32768<br \/> <br \/>\n      3 \u4fee\u6539\u5934\u6587\u4ef6: <br \/> <br \/>\n      vi \/usr\/include\/bits\/types.h <br \/> <br \/>\n      \u6ce8\u610f\uff1a\u6b64\u6587\u4ef6\u4e2d\u5e76\u65e0\u6b64\u5b9a\u4e49\uff0c\u9700\u81ea\u5df1\u6dfb\u52a0\u8fdb\u53bb<br \/>\n      #undef __STD_TYPE <br \/> <br \/>\n      #define __FD_SETSIZE 32768 <br \/> <br \/>\n      #endif \/* bits\/types.h *\/ <\/p>\n<p>\n      \u7136\u540e\u914d\u7f6e\u7f16\u8bd1\u5b89\u88c5squid<\/p>\n<p>#log\u8bb0\u5f55\u95ee\u9898\n      <\/p>\n<p>\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u6709\u65e0log\u8bb0\u5f55\u5bf9squid\u65e0\u5f71\u54cd\uff0c\u4f46\u5982\u679c\u670d\u52a1\u91cf\u8fc7\u5927\uff0c\u4f1a\u56e0\u4e3alog\u6587\u4ef6\u5927\u4e8e\u7cfb\u7edf\u8bb8\u8fc7\u7684\u6700\u5927\u6587\u4ef6\u65f6\uff0csquid\u5c31\u4f1a\u505c\u6389\u3002\u8fd9\u4e5f\u662f\u5f88\u591a\u7f51\u4e0a\u4eba\u6240\u8bf4\u7684squid\u7528\u7528\u5c31\u4f1a\u6162\u6216\u6b7b\u6389\u7684\u4e00\u4e2a\u539f\u56e0\u3002\n      <\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\u5f88\u7b80\u5355\uff0c\u8981\u4e0d\u589e\u5927\u7cfb\u7edf\u8bb8\u53ef\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u8981\u4e0d\u76f4\u63a5\u7981\u7528log,\u5982\u4e0b\uff1a\n      <\/p>\n<p>      access_log none<br \/>cache_store_log none  <\/p>\n<p>#\u4e0d\u53ef\u7f13\u5b58\u7684\u7f51\u9875<\/p>\n<p>\u6709\u4e9b\u7f51\u9875\u5982\u679c\u7f13\u5b58\u4e86\uff0c\u53ea\u663e\u793a\u65e7\u7684\u7f51\u9875\uff0c\u53ef\u4ee5\u5982\u4e0b\u89e3\u51b3\uff1a<\/p>\n<p>acl nocacheweb urlpath_regex -i \\.asp \\.aspx \\.php \\.jsp \\.html \\.shtml<br \/>\n      \\.cgi<br \/>\n      no_cache deny nocacheweb\n      <\/p>\n<p>#DNS\u8f6e\u8be2\u5e26\u6765\u7684\u95ee\u9898<\/p>\n<p>\u6709\u4e9b\u7f51\u7ad9\u4f7f\u7528\u4e86DNS\u8f6e\u8be2\uff0c\u7ed3\u679cSQUID\u6bcf\u6b21\u6253\u5f00\u7f51\u9875\u4f7f\u7528\u7684\u90fd\u4e0d\u662f\u540c\u4e2a\u670d\u52a1\u5668\u7684\uff0c\u6b64\u7ad9\u7684\u767b\u5f55\u81ea\u7136\u4e5f\u4f1a\u51fa\u9519\uff0c\u53ef\u4ee5\u5982\u4e0b\u89e3\u51b3\uff1a<\/p>\n<p>balance_on_multiple_ip off\n      <\/p>\n<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u7f13\u5b58\u4ee3\u7406\u670d\u52a1\u5668Squid &#8212;&#8212;&#8212;&#8212;&#8212;&#8212; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts\/153"}],"collection":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=153"}],"version-history":[{"count":1,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts\/153\/revisions"}],"predecessor-version":[{"id":154,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts\/153\/revisions\/154"}],"wp:attachment":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}