/* About ----- This directory contains extra files to make the 'fancy urls' feature even more fancier, by eliminating the 'index.php'-part of the URL Installation ------------ 1. Copy all files in this directory (except for index.html) to your main nucleus dir (where your index.php and action.php file are) If you have an already existing .htaccess file (most ftp-programs don't show hidden files by default, so don't start uploading it without checking your server). If you do, download that old one first, and copy the contents of the new .htaccess file (from the fancyurls folder) in your old one, and upload that... 2. Edit this file so that $CONF['Self'] points to your main directory. NOTE: this time, and only this time, the URL should NOT end in a slash 3. Also edit the $CONF['Self'] variable in your index.php, if you don't want to end up with index.php/item/1234 urls when people come via that way 4. Enable 'Fancy URLs' in the Nucleus admin area (nucleus management / edit settings) 5. Off you go! If it doesn't work: ------------------- Remove the files again (don't forget the hidden file .htaccess). Voila. */ // remember: this URL should _NOT_ end with a slash. $CONF['Self'] = 'http://www.momoso-net.com/~ms08'; ?>
2008-04-15: YetiBot(イエティボット)からのアクセス
Yeti/1.0 (+http://help.naver.com/robots/)なるアクセスがここにきてすごい!クローラのアクセスは必要なのかどうか分からないが、下記のLOGのようなアクセスされると(それも短い間隔で)私のサーバはスワップを使い切ってフリーズしちゃいます。
61.247.217.42 - - [05/Apr/2008:00:00:11 +0900] "GET /~ms08/r・・・省略・・・49/catid/22 HTTP/1.1" 200 25906 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
61.247.217.41 - - [05/Apr/2008:00:00:16 +0900] "GET /~ms08/r・・・省略・・・e/6/2007-11 HTTP/1.1" 200 30028 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
61.247.217.35 - - [05/Apr/2008:00:00:11 +0900] "GET /~ms08/r・・・省略・・・e/6/2007-11 HTTP/1.1" 200 29880 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
61.247.217.35 - - [05/Apr/2008:00:00:12 +0900] "GET /~ms08/r・・・省略・・・53/catid/22 HTTP/1.1" 200 28888 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
61.247.217.34 - - [05/Apr/2008:00:00:32 +0900] "GET /~ms08/r・・・省略・・・11/catid/22 HTTP/1.1" 200 28632 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
61.247.217.44 - - [05/Apr/2008:00:00:35 +0900] "GET /~ms08/r・・・省略・・・52/catid/22 HTTP/1.1" 200 25599 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
61.247.217.33 - - [05/Apr/2008:00:00:39 +0900] "GET /~ms08/r・・・省略・・・12/catid/22 HTTP/1.1" 200 30543 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
61.247.217.35 - - [05/Apr/2008:00:00:43 +0900] "GET /~ms08/r・・・省略・・・12/catid/22 HTTP/1.1" 200 27345 "-" "Yeti/1.0 (+http://help.naver.com/robots/)"
そこでせっかくアクセスして頂いているのですが、すこしばかり制御させてもらいます。
こんな感じ!!
利用するツールapp-admin/swatch-3.1を無ければインストール。
(apacheのアクセスログからIPアドレスを抽出するシェルスクリプトを作成)
場所は/etc/swatchでipselect.shのファイル名で作成
このシェルはIPを抽出しiptablesで一定時間、当該IPをDROPするもの。
#!/bin/sh
export LANG=C
IPTMPFILE="/etc/swatch/iptables.tmp" # The temporary file
IPWRKFILE="/etc/swatch/iptables.wrk" # The IP Work file
IPLOGFILE="/var/log/iptables.log" # The log file
TIME=`/bin/date +"%b %d %T"` # Now date
CANCELTIME="30 minutes" # Cancellation time 30 minutes`
/bin/echo $* > $IPTMPFILE
DROP_IP=`/bin/sed 's/\s//g' $IPTMPFILE | \
/bin/sed 's/\([0-9]*.[0-9]*.[0-9]*.[0-9]*\)\(--\S*\)/\1\n/g'`
/bin/rm -r $IPTMPFILE
CHK_IP=`/bin/echo $DROP_IP | /bin/sed 's/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*/OK/g'`
if [ "$CHK_IP" = "OK" ];
then
WORK_IP=`/bin/cat $IPWRKFILE`
if [ "$DROP_IP" != "$WORK_IP" ];
then
/sbin/iptables -A INPUT -s $DROP_IP -j DROP
/bin/echo -e "$TIME $HOSTNAME ipselect_http[$$]: The access of IP:$DROP_IP was denied with iptables" >> $IPLOGFILE
/bin/echo "/sbin/iptables -D INPUT -s $DROP_IP -j DROP" | /usr/bin/at now + $CANCELTIME > /dev/null
else
/bin/echo -e "$TIME $HOSTNAME ipselect_http[$$]: The access of IP:$DROP_IP was denied with iptables SKIP!" >> $IPLOGFILE
fi
/bin/echo $DROP_IP > $IPWRKFILE
else
/bin/echo -e "$TIME $HOSTNAME ipselect_http[$$]: The access of IP:$DROP_IP was denied with iptables NG!" >> $IPLOGFILE
fi
(そしてswatchの設定)
場所は/etc/swatchで.swatchrcのファイル名で作成
watchfor = /Yeti\/1.0/
exec `/etc/swatch/ipselect.sh \'$_\'`
これはapacheのアクセスログの中にYeti/1.0のアクセスを見つけたらipselect.shにログを解析してもらうって設定
(起動)
/etc/init.dにサービスとして登録するのが便利。ファイル名はswatchdみたいなかんじ。
#!/sbin/runscript
SWATCHD_PIDFILE="/var/run/swatchd.pid"
SWATCHD_TAILPIDFILE="/var/run/swatchd_tail.pid"
depend() {
need net
}
checkconfig() {
if [ ! -e /etc/swatch/.swatchrc ] ; then
eerror "You need an /etc/swatch/.swatchrc file first"
return 1
fi
}
start() {
checkconfig || return 1
[ -e "${SWATCHD_PIDFILE}" ] && rm -f ${SWATCHD_PIDFILE} &>/dev/null
ebegin "Starting Simple Watcher"
/usr/bin/swatch --config-file /etc/swatch/.swatchrc --tail-file=/var/log/auth.log --daemon
/bin/pidof swatch > ${SWATCHD_PIDFILE}
/bin/pidof tail > ${SWATCHD_TAILPIDFILE}
eend $?
}
stop() {
ebegin "Stopping Simple Watcher"
SWATCHD_PID=`/bin/cat ${SWATCHD_PIDFILE} | /bin/awk '{print $1}'`
/bin/kill -9 "${SWATCHD_PID}"
/bin/rm -f "${SWATCHD_PIDFILE}"
SWATCHD_TAILPID=`/bin/cat ${SWATCHD_TAILPIDFILE} | /bin/awk '{print $1}'`
/bin/kill -9 "${SWATCHD_TAILPID}"
/bin/rm -f "${SWATCHD_TAILPIDFILE}"
eend $?
}
できあがったらrc-update -a swatchd defaultでサービス登録し/etc/init.d/swatchd startで起動
これですこしはサーバの負荷がなくなるかな?
最後にLOGのローテーションの関係でaccess_log(apacheのアクセスログ)のファイルをswatchが見失うので、ローテーションのタイミングでswatchの再起動をしないとだめです。これはlogrotateで定義してください。
Category: Gentoo Linux No Trackbacks