トラフィック制御する方法(bwshare)
Created: 9 September 2007
設定の小技 (10 September 2007)
ダウンロードから基本設定まで (10 September 2007)
ファイル数で制限する方法
"BW_tx1debt_max"で指定したファイル数までは無制限ですが、越えたら制限がかかります。
"BW_tx1cred_rate"一秒間に指定した値の分だけ制限が緩められます。
BW_tx1debt_max 20 BW_tx1cred_rate 0.133上記設定(デフォルト値)の場合、"BW_tx1debt_max"が"20"なので、20ファイルまでは制限がかかりません。20を超えた場合、"BW_tx1cred_rate"が1秒間に"0.133"、つまり、1秒間に7.5ファイルずつ許可されます。
バイト数で制限する方法
"BW_tx2debt_max"で指定したバイト数までは無制限ですが、越えたら制限がかかります。
"BW_tx2cred_rate"一秒間に指定した値の分だけ制限が緩められます。
BW_tx2debt_max 3000000 BW_tx2cred_rate 2500上記設定(デフォルト値)の場合、"BW_tx2debt_max"が"3000000"なので、3Mバイトまでは制限がかかりません。3Mを超えた場合、"BW_tx2cred_rate"が1秒間に"2500"、つまり、1秒間に2.5Kバイトずつ許可されます。
特定のクライアントでのみ制限する方法
"BW_subnet_limit"で指定できます。
BW_subnet_limit net = 192.168.83.0/24 tx1rate = 80.00 files/min tx1max = 200 files tx2rate = 1000000 bits/sec tx2max = 10000000 bytes
特定のドメインを制限からはずす方法
<Virtualhost ...> : BW_throttle_off 1 Servername www.tomo.ac : </Virtualhost>
"mod_bwshare"のダウンロード
"mod_bwshare"は以下からダウンロードできます。
http://www.topology.org/src/bwshare/README.html
2007年9月9日に、"mod_bwshare-0.2.0.zip" がダウンロードできました。
"mod_bwshare"のインストール
以下の手順で実行すればインストールまで完了します。
# unzip mod_bwshare-0.2.0.zip # cd mod_bwshare-0.2.0 # apxs -i -a -c mod_bwshare.c /usr/lib/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -pthread -I/usr/include/httpd -I/usr/include/apr-1 -I/usr/include/apr-1 -c -o mod_bwshare.lo mod_bwshare.c && touch mod_bwshare.slo /usr/lib/apr-1/build/libtool --silent --mode=link gcc -o mod_bwshare.la -rpath /usr/lib/httpd/modules -module -avoid-version mod_bwshare.lo /usr/lib/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib/apr-1/build/libtool' mod_bwshare.la /usr/lib/httpd/modules /usr/lib/apr-1/build/libtool --mode=install cp mod_bwshare.la /usr/lib/httpd/modules/ cp .libs/mod_bwshare.so /usr/lib/httpd/modules/mod_bwshare.so cp .libs/mod_bwshare.lai /usr/lib/httpd/modules/mod_bwshare.la cp .libs/mod_bwshare.a /usr/lib/httpd/modules/mod_bwshare.a chmod 644 /usr/lib/httpd/modules/mod_bwshare.a ranlib /usr/lib/httpd/modules/mod_bwshare.a PATH="$PATH:/sbin" ldconfig -n /usr/lib/httpd/modules ---------------------------------------------------------------------- Libraries have been installed in: /usr/lib/httpd/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- chmod 755 /usr/lib/httpd/modules/mod_bwshare.so [activating module `bwshare' in /etc/httpd/conf/httpd.conf] #
設定する
"/etc/httpd/conf.d/bwshare.conf"を以下のように作成します。
LoadModule bwshare_module /usr/lib/httpd/modules/mod_bwshare.so <Location /bwshare-info> SetHandler bwshare-info Order deny,allow Deny from all Allow from 192.168.83. </Location> <Location /bwshare-trace> SetHandler bwshare-trace Order deny,allow Deny from all Allow from 192.168.83. </Location> <Directory /> BW_tx1debt_max 20 BW_tx1cred_rate 0.133 BW_tx2debt_max 3000000 BW_tx2cred_rate 2500 BW_subnet_limit net = 192.168.83.0/24 tx1rate = 80.00 files/min \ tx1max = 200 files tx2rate = 1000000 bits/sec tx2max = 10000000 bytes </Directory>
管理画面を開いてみる
"http://(hostname)/bwshare-info"を開いてみます。
"http://(hostname)/bwshare-trace"を開いてみます。