{"id":442,"date":"2015-01-07T08:59:49","date_gmt":"2015-01-07T00:59:49","guid":{"rendered":"http:\/\/www.datarelab.com\/blog\/?p=442"},"modified":"2015-01-18T18:59:40","modified_gmt":"2015-01-18T10:59:40","slug":"linux%e4%b8%8b%e5%ae%89%e8%a3%85mod_bw%e5%92%8cmod_limitipconn%e9%99%90%e5%88%b6apache%e5%b9%b6%e5%8f%91%e8%bf%9e%e6%8e%a5%e5%92%8c%e4%b8%8b%e8%bd%bd%e9%80%9f%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/www.datarelab.com\/blog\/Technical_literature\/442.html","title":{"rendered":"Linux\u4e0b\u5b89\u88c5mod_bw\u548cmod_limitipconn\u9650\u5236apache\u5e76\u53d1\u8fde\u63a5\u548c\u4e0b\u8f7d\u901f\u5ea6"},"content":{"rendered":"<p>mod_limitipconn\uff0c\u8fd9\u4e2a\u662fApache\u7684\u4e00\u4e2a\u975e\u5b98\u65b9\u6a21\u5757\uff0c\u6839\u636e\u540c\u4e00\u4e2a\u6765\u6e90IP\u8fdb\u884c\u5e76\u53d1\u8fde\u63a5\u63a7\u5236\uff0cBw_mod\uff0c\u5b83\u53ef\u4ee5\u6839\u636e\u6765\u6e90IP\u8fdb\u884c\u5e26\u5bbd\u9650\u5236\uff0c\u5b83\u4eec\u90fd\u662fapache\u7684\u7b2c\u4e09\u65b9\u6a21\u5757\u3002<br \/>\n<strong>1.<\/strong>\u4e0b\u8f7d\uff1a wget http:\/\/dominia.org\/djao\/limit\/mod_limitipconn-0.22.tar.gz wget http:\/\/bwmod.sourceforge.net\/files\/mod_bw-0.7.tgz<br \/>\n<strong>2.<\/strong>\u5b89\u88c5#tar -zxvf mod_limitipconn-0.22.tar.gz<br \/>\n#cd mod_limitipconn-0.22<br \/>\n#vi Makefile<br \/>\n\u4fee\u6539\uff1aapxs = \u201c\/usr\/local\/apache2\/bin\/apxs\u201d # \u8fd9\u91cc\u662f\u81ea\u5df1apache\u7684apxs\u8def\u5f84\uff0c\u52a0\u8f7d\u6a21\u5757\u6216\u8005#\/usr\/local\/apache2\/bin\/apxs -i -c -a mod_limitipconn.c \u6765\u52a0\u8f7d\u6a21\u5757<br \/>\n#make<br \/>\n#make install#tar -xvf mod_bw-0.7.tgz<br \/>\n#cd mod_bw<br \/>\n#\/usr\/local\/apache2\/bin\/apxs -i -c -a \/home\/kenami\/mod_bw\/mod_bw.c\u4e0b\u9762\u7528vi\u6253\u5f00apache \u7684\u914d\u7f6e\u6587\u4ef6 httpd.conf\u53d1\u73b0\u4e86\u4ee5\u4e0b\u4e24\u884c\uff1aLoadModule limitipconn_module modules\/mod_limitipconn.so<\/p>\n<p>LoadModule bw_module modules\/mod_bw.so<br \/>\n<strong>3.<\/strong>\u914d\u7f6e<br \/>\n&lt;IfModule mod_limitipconn.c&gt;<br \/>\n&lt;Location \/home\/bo@phpddt.com\/attachments\/month _*&gt; #\u9700\u8981\u63a7\u5236\u7684\u8def\u5f84<br \/>\nMaxConnPerIP 3 #\u9650\u5236\u7684\u7ebf\u7a0b\u6570<br \/>\nNoIPLimit index.htm #\u5bf9\u6b64\u6587\u4ef6\u4e0d\u505a\u9650\u5236<br \/>\n&lt;\/Location&gt;<br \/>\n&lt;\/IfModule&gt;\u5728\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6\u4e0b\u9762\u52a0\u4e0a\uff1a BandwidthModule On<br \/>\nForceBandWidthModule On<br \/>\nBandwidth all 10000 #\u9650\u901f10K<br \/>\nMinBandwidth all -1<br \/>\n\u914d\u7f6e\u53c2\u6570\u8bf4\u660e\u5982\u4e0b\uff1a<br \/>\na. BandWidthModule On|Off\/\/\u662f\u5426\u5f00\u542fmod_bw\u7684\u5e26\u5bbd\u9650\u5236\u529f\u80fd\u3002<br \/>\nb. BandWidth [From] [bytes\/s] \u8bbe\u7f6e\u6307\u5b9a\u5ba2\u6237\u673a\u6700\u5927\u5e26\u5bbd,0\u8868\u793a\u4e0d\u9650\u5236 BandWidth u:[User-Agent] [bytes\/s]<br \/>\nc. MinBandWidth [From] [bytes\/s] \u8bbe\u7f6e\u6307\u5b9a\u5ba2\u6237\u673a\u5e26\u5bbd\u7684\u6700\u5c0f\u503c\uff0c\u4e3a0\u8868\u793a\u6bcf\u4e2a\u5ba2\u6237\u7aef\u5e26\u5bbd\u6700\u5927\u4e3a256bytes\/s,\u4e3a-1\u8868\u793a\u6700\u5927\u4e3aBandWith\u7684\u503c<br \/>\nd. LargeFileLimit [Type] [Minimum Size] [bytes\/s] \u8bbe\u7f6e\u8bbf\u95ee\u8d85\u51fa\u7279\u5b9a\u5927\u5c0f\u7684\u67d0\u79cd\u6587\u4ef6\u7684\u6700\u5927\u5e26\u5bbd,\u6587\u4ef6\u7c7b\u578b\u5927\u5c0f\u5355\u4f4d\u4e3akbytes<br \/>\ne. MaxConnection [From] [Max] \u8bbe\u7f6e\u6307\u5b9a\u5ba2\u6237\u673a\u7684\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u6570<br \/>\nf. ForceBandWidthModule [On|Off] \u9ed8\u8ba4bw\u6a21\u5757\u5c06\u5e94\u7528\u6240\u6709\u8bf7\u6c42\uff0cOn\u53ef\u8bbe\u7f6e\u8fc7\u6ee4\u7c7b\u578b\u5173\u4e8eFrom\uff0c\u5373\u5ba2\u6237\u7aef\u6765\u6e90\u53ef\u5206\u4ee5\u4e0b\u51e0\u79cd\u60c5\u51b5\uff1aIP\u6307\u5b9a\u5355\u4e00\u4e3b\u673a192.168.1.22\u6307\u5b9a\u7f51\u6bb5192.168.1.0\/24\u6216192.168.1.0\/255.255.255.0\u57df\u540d\u5355\u4e00\u4e3b\u673aClient1.phpddt.com\u57df\u540d\u6307\u5b9a\u8303\u56f4.phpddt.com\u6240\u6709\u5ba2\u6237\u7aefall\u4ee5\u4e0a\u914d\u7f6e\u65e2\u53ef\u4ee5\u9488\u5bf9\u6240\u6709\u5ba2\u6237\u7aef\uff0c\u4e5f\u53ef\u4ee5\u5bf9\u67d0\u4e2a\u865a\u62df\u4e3b\u673a\u8fdb\u884c\u914d\u7f6e\u5b9e\u4f8b\u4e00\uff1aBandWidthModule OnBandWidth all 307200BandWidth 192.168.1.2 102400BandWidth \u201cu:^Mozilla\/5(.*)\u201d 102400BandWidth \u201cu:wget\u201d 204800ForceBandWidthModule OnLargeFileLimit .avi 600 204800MaxConnection all 100MaxConnnection 192.168.1.2 5\u4ee5\u4e0a\u7684\u914d\u7f6e\u542b\u4e49\uff1a\u5f00\u542fmod_bw, \u9650\u5236\u6240\u6709\u6587\u4ef6\u7c7b\u578b\u4e5f\u5f00\u542f\u4e86\u6240\u6709\u5ba2\u6237\u7aef\u6700\u5927\u5e26\u5bbd\u4e3a300k,\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u4e3a100192.168.1.2\u7684\u6700\u5927\u5e26\u5bbd\u4e3a100k,\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u4e3a5\u4f7f\u7528FireFox\u7684\u5ba2\u6237\u7aef\u6700\u5927\u5e26\u5bbd\u4e3a100k\u4f7f\u7528wget\u7684\u5ba2\u6237\u7aef\u6700\u5927\u5e26\u5bbd\u4e3a200k\u5bf9\u8d85\u8fc7600k\u7684avi\u683c\u5f0f\u7684\u6587\u4ef6\u6700\u5927\u5e26\u5bbd\u4e3a200kbyte\/s\u5b9e\u4f8b\u4e8c\uff1a&lt;Virtualhost *&gt; BandwidthModule On ForceBandWidthModule On LargeFileLimit .avi 1 20000 LargeFileLimit .mpg 1 20000 Servername www.phpddt.com&lt;\/Virtualhost&gt;\u8be5\u5b9e\u4f8b\u5bf9\u865a\u62df\u4e3b\u673a\u8fdb\u884c\u4e86\u9650\u5236\uff0c\u6307\u5b9a\u7684\u6587\u4ef6\u7c7b\u578bavi\u548cmpg\u6700\u5927\u5e26\u5bbd\u4e3a20K,ForceBandWidthModule On\u5fc5\u987b\u6709\u3002\u5b9e\u4f8b\u4e09\uff1a&lt;Virtualhost *&gt; BandwidthModule On AddOutputFilterByType MOD_BW text\/html text\/plain Bandwidth all 5000 Servername www.phpddt.com &lt;\/Virtualhost&gt;<\/p>\n<p><span style=\"color: #000000; font-family: 'sans serif', tahoma, verdana, helvetica; font-size: 12px; line-height: 18px;\">\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mod_limitipconn\uff0c\u8fd9\u4e2a\u662fApache\u7684\u4e00\u4e2a\u975e\u5b98\u65b9\u6a21\u5757\uff0c\u6839\u636e\u540c\u4e00\u4e2a\u6765\u6e90IP\u8fdb\u884c\u5e76\u53d1\u8fde\u63a5\u63a7\u5236\uff0cBw_ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[129,14],"class_list":["post-442","post","type-post","status-publish","format-standard","hentry","category-Technical_literature","tag-apache","tag-linux"],"views":1684,"_links":{"self":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/comments?post=442"}],"version-history":[{"count":0,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/442\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/media?parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/categories?post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/tags?post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}