Jump to content
Compatible Support Forums
Sign in to follow this  
dje007

Can Apache limit connections

Recommended Posts

Can Apache limit connections, per IP address.

So that it can serve one user a max of say 4 con's

Share this post


Link to post

howdy dje007

 

Yes, you can tell Apache exactly how it should handle requests and how many processes there sould be to serve requests. In particular you will find the settings plus the respective descriptions in either the file "httpd.conf" (Apache 1.3.xx), or "httpd2.conf" (Apache 2.0.xx) which are loccated under "/etc/httpd/conf" (for most apache versions). The settings to look for would be ...

 

StartServers

MinSpareServers

MaxSpareServers

MaxClients

MaxRequestsPerChild

 

(and maybe some other)

 

As it goes for connections per IP handled by multiple apaches on one machine ...

 

You'd need to simply start Apache twice with different conf-files to get different connection settings for different interfaces. In brief a setup like this would look like this ...

 

Apache 1:

installed in "/usr/local/apache1"

is started/stopped via "/etc/init.d/apache1"

(this startup script also tells the server which config file to use, e.g. "/etc/httpd/conf1/httpd.conf" and uses the above conf-file which contains ...

 

Code:
Listen 111.111.111.111:80

 

This tells the first server to only listen on this specific IP. Also, set the spare-servers/requests-settings as mentioned above to your liking.

 

Apache 2:

installed in "/usr/local/apache2"

is started/stopped via "/etc/init.d/apache2"

which tells the 2nd server to use e.g. "/etc/httpd/conf2/httpd.conf" which contains ...

 

Code:
Listen 222.222.222.222:80

 

As you can see, running multiple Apaches for the sake of individual request-handling can get a tad complex, especially with Apache 2-series server, which use a flock of config files that you'd need to seperate or keep unique according to your needs. Also the startup scripts need to reference the different servers. But in general: What you ask is in fact possible (I suppose smile

 

hope that helps

 

(edited due to hasty typing smile

Share this post


Link to post

Thats fine but I need to stop some ip's from using lots of cons.

i.e users that are opening 100's of con's

 

I have 2000 active cons from the same ip some times and I need to stop the using all the system bandwith

Share this post


Link to post

I see ... then you'd need to incorporate some MaxKeepAliveRequests as described in the manual ...

 

<snip>

MaxKeepAliveRequests directive

Syntax: MaxKeepAliveRequests number

Default: MaxKeepAliveRequests 100

Context: server config

Status: core

Compatibility: Only available in Apache 1.2 and later.

 

The MaxKeepAliveRequests directive limits the number of requests allowed per connection when KeepAlive is on. If it is set to "0", unlimited requests will be allowed. We recommend that this setting be kept to a high value for maximum server performance. In Apache 1.1, this is controlled through an option to the KeepAlive directive.

 

For example: MaxKeepAliveRequests 500

<snip>

(from the Apache 1.3 manual)

 

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×