mod_limitipconn.c是一个非官方的apache模块,可以用来作为WEB文件的下载限制
,但是它是使用ExtendedStatus On形式,工作在应用层。当同一个IP的连接到达
限制的时候,apache对get请求发送:
HTTP/1.1 503 Service Temporarily Unavailable
从而使用户不能下载,但并不能阻止这种攻击,仍旧允许连接的。不过这个东东对
网管来说还是很有用的,特别是下载站的网管。简单介绍一下安装(动态模块方式
安装,假设你的apache已经装在/usr/local/apache目录下):
下载:http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz
# tar xzf mod_limitipconn-0.22.tar.gz
# cd mod_limitipconn-0.22
# vi Makefile
把第一行的:
APXS = apxs
改为
APXS = /usr/local/apache/bin/apxs
然后:
# make
# make install
修改apache配置文件:
# vi /usr/local/apache/conf/httpd.conf
ExtendedStatus On ###make install时这句前面的#没有去掉,一定要去掉
###make install已经加了下面两句,确认存在就行了
LoadModule limitipconn_module /usr/lib/apache/mod_limitipconn.so
###下面就是对web目录下的文件下载限制
MaxConnPerIP 3 ###限制web根目录同一个IP只能同时开3进程下载
# 还有其它选项,如:
# NoIPLimit image/*
# OnlyIPLimit audio/mpeg audio/x-pn-realaudio video
# 可以设置多个Location
MaxConnPerIP 3
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
NoIPLimit image/*
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg audio/x-pn-realaudio video
重启apache,用多线程的下载工具下载时,大于3个线程,其余的将得到信息:
HTTP/1.1 503 Service Temporarily Unavailable
或者根据User_Agent判断,把已知的多线程工具都给deny 掉
in httpd.conf
.....
BrowserMatch "NetAnt" badguy
BrowserMatch "GetRight" badguy
BrowserMatch "JetCar" badguy
BrowserMatch "Mass Downloader" badguy
BrowserMatch "ReGet" badguy
BrowserMatch "DLExpert" badguy
BrowserMatch "FlashGet" badguy
BrowserMatch "Offline Explorer" badguy
BrowserMatch "Teleport" badguy
...........
order deny,allow
deny from env=badguy
allow from all
注意httpd里面应该有 mod_setenvif模块