Home Operation and Maintenance Linux Operation and Maintenance How to limit concurrent connections and download speed in Linux apache

How to limit concurrent connections and download speed in Linux apache

May 12, 2023 am 10:49 AM
linux apache

mod_limitipconn, this is an unofficial module of Apache, which controls concurrent connections based on the same source IP, bw_mod, which can limit bandwidth based on the source IP, they are both third-party modules of Apache.

1. Download:

wget

wget

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 own apache apxs path, load the 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_bw.c

Use vi to open the apache configuration file httpd.conf

and find the following two lines:

loadmodule limitipconn_module modules/mod_limitipconn.so


loadmodule bw_module     modules/mod_bw.so

3. Configuration


 < location /home/bo@jb51.net/attachments/month _*> #Path to be controlled
maxconnperip 3 #Number of threads to limit
noiplimit index.htm #No restrictions on this file
< ;/location>

Add below the virtual host configuration file:

bandwidthmodule on
forcebandwidthmodule on
bandwidth all 10000 #speed limit 10k
minbandwidth all -1


The configuration parameter description is as follows:
a. bandwidthmodule on|off

//Whether to enable the bandwidth limitation function of mod_bw.

b. bandwidth [from] [bytes/s]

Set the maximum bandwidth of the specified client, 0 means no limit

bandwidth u:[user-agent] [bytes /s]

c. minbandwidth [from] [bytes/s]

Set the minimum value of the specified client bandwidth. If it is 0, it means that the maximum bandwidth of each client is 256bytes/s. -1 represents the maximum value of bandwith

d. largefilelimit [type] [minimum size] [bytes/s]

Set the maximum bandwidth for accessing a certain file exceeding a specific size, file type The size unit is kbytes

e. maxconnection [from] [max]

Set the maximum number of concurrent connections for the specified client

f. forcebandwidthmodule [on|off]

The default bw module will apply to all requests, on can set the filtering type

Regarding from, that is, the client source can be divided into the following situations:

ip specifies a single host

192.168.1.22

Specify the network segment

192.168.1.0/24 or

192.168.1.0/255.255.255.0

Domain name single host

client1.jb51.net

Domain name specified range

.jb51.net

All clients

all

The above configuration can be configured for all clients or a certain virtual host

Example 1:

bandwidthmodule on

bandwidth all 307200

bandwidth 192.168.1.2 102400

bandwidth “u:^mozilla/5(.*)” 102400

bandwidth “u:wget” 204800

forcebandwidthmodule on

largefilelimit .avi 600 204800

maxconnection all 100

maxconnnection 192.168.1.2 5

The above configuration meaning:

Enable mod_bw, and limit all file types.

The maximum bandwidth of all clients is 300k, and the maximum concurrent connections are 100

The maximum bandwidth of 192.168.1.2 is 100k, and the maximum concurrent connections is 5

The maximum bandwidth of the client using firefox is 100k

The maximum bandwidth of the client using wget is 200k

The maximum bandwidth of the avi format file exceeding 600k is 200kbyte/s

Example 2:

bandwidthmodule on

forcebandwidthmodule on

largefilelimit .avi 1 20000

largefilelimit .mpg 1 20000

servername

This instance limits the virtual host. The specified The maximum bandwidth of file types avi and mpg is 20k, and forcebandwidthmodule on is required.

Example 3:

bandwidthmodule on

addoutputfilterbytype mod_bw text/html text/plain

bandwidth all 5000

servername

The above is the detailed content of How to limit concurrent connections and download speed in Linux apache. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Android TV Box gets unofficial Ubuntu 24.04 upgrade Android TV Box gets unofficial Ubuntu 24.04 upgrade Sep 05, 2024 am 06:33 AM

Android TV Box gets unofficial Ubuntu 24.04 upgrade

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

deepseek web version entrance deepseek official website entrance

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

How to install deepseek

BitPie Bitpie wallet app download address BitPie Bitpie wallet app download address Sep 10, 2024 pm 12:10 PM

BitPie Bitpie wallet app download address

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet official website installation (2025 beginner's guide)

Detailed explanation: Shell script variable judgment parameter command Detailed explanation: Shell script variable judgment parameter command Sep 02, 2024 pm 03:25 PM

Detailed explanation: Shell script variable judgment parameter command

Zabbix 3.4 Source code compilation installation Zabbix 3.4 Source code compilation installation Sep 04, 2024 am 07:32 AM

Zabbix 3.4 Source code compilation installation

Ouyi okx installation package is directly included Ouyi okx installation package is directly included Feb 21, 2025 pm 08:00 PM

Ouyi okx installation package is directly included

See all articles