Use MOD_LIMITIPCONN.C to limit the number of concurrent Apache

Source: Internet
Author: User
Tags diff
use MOD_LIMITIPCONN.C to limit the number of concurrent Apache

Linux Technology Backbone Station 2002-12-12

Download Mod_limitipconn.c tar.gz i386 rpm (Proxy client detection feature not enabled) source rpm

I'm using the tar package to download the mod_limitipconn-0.04.tar.gz, which is already available to support Apache2, to execute on the server

# wget http://dominia.org/djao/limit/mod_limitipconn-0.04.tar.gz Download to local

Then execute the following command to compile the installation. My Apache is in the/usr/local/apache directory

Decompression:

[Root@ns chenlf]# tar zxvf mod_limitipconn-0.04.tar.gz
mod_limitipconn-0.04/
Mod_limitipconn-0.04/makefile
Mod_limitipconn-0.04/readme
Mod_limitipconn-0.04/apachesrc.diff
Mod_limitipconn-0.04/mod_limitipconn.c
Mod_limitipconn-0.04/changelog

Compile Installation:


[Root@ns chenlf]# CD mod_limitipconn-0.04
[Root@ns mod_limitipconn-0.04]# ls
Apachesrc.diff changelog Makefile mod_limitipconn.c README
[Root@ns mod_limitipconn-0.04]#/usr/local/apache/bin/apxs-c-i-a mod_limitipconn.c
Gcc-dlinux=22-i/usr/include/db1-fpic-dshared_module-i/usr/local/apache/include-c MOD_LIMITIPCONN.C
Gcc-shared-o mod_limitipconn.so MOD_LIMITIPCONN.O
[Activating module ' Limitipconn ' in/usr/local/apache/conf/httpd.conf]
CP mod_limitipconn.so/usr/local/apache/libexec/mod_limitipconn.so
chmod 755/usr/local/apache/libexec/mod_limitipconn.so
Cp/usr/local/apache/conf/httpd.conf/usr/local/apache/conf/httpd.conf.bak
Cp/usr/local/apache/conf/httpd.conf.new/usr/local/apache/conf/httpd.conf
Rm/usr/local/apache/conf/httpd.conf.new

To modify a configuration file:

1 Global control:

Add the following lines to the httpd.conf:

<ifmodule mod_limitipconn.c>
<location/> # All virtual Host/directory
Maxconnperip 3 # Only 3 concurrent connections per IP allowed
Noiplimit image/* # Don't make IP restrictions on pictures
</Location>

<Location/mp3> #/mp3 directory for all hosts
Maxconnperip 1 # Only one connection request per IP allowed
Onlyiplimit audio/mpeg Video # This limit is only for videos and audio format files
</Location>
</IfModule>

2 Local restrictions, you can also set the IP limit in the configuration file of the virtual host, the method is exactly the same:

<virtualhost xx.xxx.xx.xx>
ServerAdmin chenlf@chinalinuxpub.com
Documentroot/home/my
ServerName www.my.com
<ifmodule mod_limitipconn.c>
<location/> # All virtual Host/directory
Maxconnperip 5 # Only 3 concurrent connections per IP allowed
Noiplimit image/* # Don't make IP restrictions on pictures
</Location>
<Location/mp3> #/mp3 directory for all hosts
Maxconnperip 2 # Only one connection request per IP allowed
Onlyiplimit audio/mpeg Video # This limit is only for videos and audio format files
</Location>
</IfModule>
Errorlog/home/my/logs/error_log
Customlog/home/my/logs/access_log Common
</VirtualHost>

3 In addition, the Apache Extendedstatus must be set to on. Found in httpd.conf.
# Extendedstatus on
Remove the previous comment

All right, all the configurations are over, and the Apache will be back in effect.

                                                                                               

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.