Linux限制apache的每个IP访问的并发数
时间:2007-02-27 来源:cbs20
Linux限制apache的每个IP访问的并发数
官方网站
http://dominia.org/djao/limitipconn2.html wget http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz tar -zxvf mod_limitipconn-0.22.tar.gz cd mod_limitipconn-0.22
#注意 apache 的安装要使用 --with-mod=so
#假设apache的安装目录是 /usr/local/apache
/usr/local/apache/bin/apxs -c -i -a mod_limitipconn.c vi httpd.conf #确定下面的一行已经存在
LoadModule limitipconn_module lib/apache/mod_limitipconn.so
添加以下的行: <IfModule mod_limitipconn.c>
<Location /somewhere>
MaxConnPerIP 3 #每IP只允许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/*
</Location> <Location /mp3>
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video
</Location>
</IfModule> 去掉 #ExtendedStatus On 前面的#,使其生效
然后重启apache即可
http://dominia.org/djao/limitipconn2.html wget http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz tar -zxvf mod_limitipconn-0.22.tar.gz cd mod_limitipconn-0.22
#注意 apache 的安装要使用 --with-mod=so
#假设apache的安装目录是 /usr/local/apache
/usr/local/apache/bin/apxs -c -i -a mod_limitipconn.c vi httpd.conf #确定下面的一行已经存在
LoadModule limitipconn_module lib/apache/mod_limitipconn.so
添加以下的行: <IfModule mod_limitipconn.c>
<Location /somewhere>
MaxConnPerIP 3 #每IP只允许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/*
</Location> <Location /mp3>
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video
</Location>
</IfModule> 去掉 #ExtendedStatus On 前面的#,使其生效
然后重启apache即可
相关阅读 更多 +