ubuntu16.04 apache2.4 安装mod_bw和m
2020-08-16 本文已影响0人
simonsgj
1. mod_bw
apt-get install libapache2-mod-bw
sudo a2enmod bw
配置
<VirtualHost *:8080>
ServerName www.abc.com
ServerAlias www.abc.com
DocumentRoot /var/www/abc
# Turn bandwidth limitation on
BandwidthModule On
# force limitation on every request
ForceBandWidthModule On
# limit to 500kB/s
Bandwidth all 504800
# Setup custom error message
ErrorDocument 510 /errors/maxconexceeded.html
BandWidthError 510
# Limit avi and mpg extensions to 20kb/s.
LargeFileLimit .avi 1 20000
LargeFileLimit .mpg 1 20000
</VirtualHost>
2.mod_limitipconn
wget http://dominia.org/djao/limit/mod_limitipconn-0.24.tar.bz2
tar xf mod_limitipconn-0.24.tar.bz2
cd mod_limitipconn-0.24
apxs -c -i -a mod_limitipconn.c
ps:该步会自动将mod_limitipconn.so模块编译到apache对应的modules中,还会在http.conf文件中自动添加loadmodules语句
2.1 确保加载了mod_status模块
2.2 确保ExtendedStatus On
2.3 配置
#mod_limitipconn
LoadModule limitipconn_module /usr/lib64/httpd/modules/mod_limitipconn.so
<IfModule mod_limitipconn.c>
MaxConnPerIP 15
NoIPLimit image/*
NoIPLimit text/css
NoIPLimit application/x-javascript
<LocationMatch "/test/test\.php">
MaxConnPerIP 3
</LocationMatch>
</IfModule>