Mod_limitipconn, an unofficial module of Apache, which controls concurrent connections based on the same source IP address.
Mod_limitipconn is an unofficial module of Apache. it controls concurrent connections based on the same source IP address. Bw_mod can limit the bandwidth based on the source IP address. these are all third-party modules of apache.
1. download:
Wget http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz
Wget http://bwmod.sourceforge.net/files/mod_bw-0.7.tgz
2. Installation
# Tar-zxvf mod_limitipconn-0.22.tar.gz
# Cd mod_limitipconn-0.22
# Vi Makefile
Modify: apxs = "/usr/local/apache2/bin/apxs" # Here is your apache apxs path, loading module
Or
#/Usr/local/apache2/bin/apxs-I-c-a mod_limitipconn.c to load the module
# Make
# Make install
# Tar-xvf mod_bw-0.7.tgz
# Cd mod_bw
#/Usr/local/apache2/bin/apxs-I-c-a/home/kenami/mod_bw/mod_b1_c
Use vi to open the configuration file httpd. conf of apache.
The following two lines are found:
LoadModule limitipconn_module modules/mod_limitipconn.so
LoadModule bw_module modules/mod_bw.so
3. configuration
# Path to be controlled
MaxConnPerIP 3 # Number of restricted threads
NoIPLimit index.htm # no restrictions on this file
Add the following content to the VM configuration file:
BandwidthModule On
ForceBandWidthModule On
Bandwidth all 10000 # Speed limit 10 K
MinBandwidth all-1
The configuration parameters are described as follows:
A. BandWidthModule On | Off
// Whether to enable the bandwidth limit function of mod_bw.
B. BandWidth [From] [bytes/s]
Sets the maximum bandwidth of the specified client. 0 indicates no limit.
BandWidth u: [User-Agent] [bytes/s]
C. MinBandWidth [From] [bytes/s]
Set the minimum bandwidth of the specified client. if it is 0, the maximum bandwidth of each client is 256 bytes/s. If it is-1, the maximum bandwidth is BandWith.
D. LargeFileLimit [Type] [Minimum Size] [bytes/s]
Sets the maximum bandwidth for accessing a file that exceeds the specified size. the file type unit is kbytes.
E. MaxConnection [From] [Max]
Sets the maximum number of concurrent connections of a specified client.
F. ForceBandWidthModule [On | Off]
All requests are applied by the bw module by default, and filter types can be set On.
About From, that is, the client source can be divided into the following situations:
IP address specifies a single host
192.168.1.22
Specified CIDR block
192.168.1.0/24 or
192.168.1.0/255.255.255.0
Single domain name host
Client1.phpddt.com
Domain name range
.Phpddt.com
All clients
All
The preceding configuration can be used for all clients or a virtual host.
Instance 1:
BandWidthModule On
BandWidth all 307200
BandWidth: 192.168.1.2 102400
BandWidth "u: ^ Mozilla/5 (. *)" 102400
BandWidth u: wget 204800
ForceBandWidthModule On
LargeFileLimit. avi600 204800
Maxconnections all 100
MaxConnnection 192.168.1.2 5
The preceding configuration description:
Enable mod_bw and restrict all file types.
The maximum bandwidth of all clients is 300 k, and the maximum concurrent connection is 100.
The maximum bandwidth of 192.168.1.2 is 100 k, and the maximum concurrent connection is 5
The maximum bandwidth of clients using FireFox is 100 kB.
The maximum bandwidth of the client that uses wget is 200 KB.
The maximum bandwidth for files in avi format exceeding 200 kb is kbyte/s.
Example 2:
BandwidthModule On
ForceBandWidthModule On
LargeFileLimit. avi 1 20000
LargeFileLimit. mpg 1 20000
Servername www.phpddt.com
This instance limits the VM. The maximum bandwidth of the specified file type avi and mpg is 20 K, and the ForceBandWidthModule On must exist.
Example 3:
BandwidthModule On
AddOutputFilterByType MOD_BW text/html text/plain
Bandwidth all 5000
Servername www.phpddt.com