Web Hosting Talk


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : HOWTO: Limit Ip connections
Reply

Hosting Security and Technology Tutorials Tutorials related to server security or the like.

 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-11-2004, 09:01 PM
Blueheaven Blueheaven is offline
View Beta Profile
Web Hosting Evangelist
 
Join Date: Apr 2004
Posts: 465
HOWTO: Limit Ip connections

Installing mod_limitipconn.c
http://dominia.org/djao/

Intro
============
This is the distribution page for the Apache module mod_limitipconn.c, which
allows web server administrators to limit the number of simultaneous downloads
permitted from a single IP address.

Why did I write this module? Well, I run an mp3 server which since its
inception was being constantly hosed by people who were trying to download
dozens of files at once. For months I scoured the Internet looking for a code
snippet that would solve this problem. The closest thing I found was this patch
against an old version of Apache, and it didn't run properly on my Linux box
(that was back then; nowadays, the patch doesn't even apply cleanly to the
Apache source tree).

Finally I gave up and decided to write something to do the job myself, and
here's the result.
=================
Log into ssh

cd /usr/src
wget http://dominia.org/djao/limit/mod_li...nn-0.04.tar.gz
tar xzvf mod_limitipconn-0.04.tar.gz
cd mod_limitipconn-0.04

pico Makefile
find the line that reads APXS=apxs[/b]
change that to
APXS=/usr/local/apache/bin/apxs

press cntrl O to save
then cntrl X

// if your locations to apxs is different
locate apxs and copy the path
then paste that in
//

make
make install

service httpd restart

pico -w /etc/httpd/conf/httpd.conf

locate ExtendedStatus
Make sure ExtendedStatus is on and without the comment at the start

and add this line to every virtual directory you want to limit
or add it once to the main directory to limit all

<IfModule mod_limitipconn.c>
<Location /somewhere>
MaxConnPerIP 3
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
NoIPLimit image/*
</Location>

<Location /mp3>
MaxConnPerIP 1
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video
</Location>
</IfModule>


press cntrl O to save
then cntrl X
then service httpd restart


Last edited by Blueheaven; 12-11-2004 at 09:08 PM.
Reply With Quote
Sponsored Links
  #2  
Old 12-13-2004, 01:48 PM
smtalk smtalk is offline
View Beta Profile
Newbie
 
Join Date: Nov 2004
Location: Lithuania, EU
Posts: 21
Thats great.

Reply With Quote
  #3  
Old 12-16-2004, 07:32 AM
Flipe.NET Flipe.NET is offline
View Beta Profile
Junior Guru
 
Join Date: Oct 2004
Location: Brasil
Posts: 244
Very good.
Someday i ll need to use it.
Tnks

__________________
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former" Albert Einstein

Reply With Quote
Sponsored Links
  #4  
Old 01-01-2005, 11:42 PM
beniceman beniceman is offline
View Beta Profile
Junior Guru Wannabe
 
Join Date: Jul 2002
Posts: 56
i have followed all of the instructions above but it still did not work.

I did change the location /somewhere to the directory I want to limit

Any ideas to correct that? please help

Reply With Quote
  #5  
Old 01-02-2005, 03:11 AM
Blueheaven Blueheaven is offline
View Beta Profile
Web Hosting Evangelist
 
Join Date: Apr 2004
Posts: 465
I've only managed to get it working under each seperate virtual host and in that I have something like this.

<IfModule mod_limitipconn.c>
<Location />
MaxConnPerIP 3
NoIPLimit image/*
</Location>
</IfModule>

hope that helps

Reply With Quote
  #6  
Old 01-02-2005, 03:07 PM
Blue Eyes Blue Eyes is offline
View Beta Profile
Junior Guru Wannabe
 
Join Date: Dec 2004
Posts: 30
Thanks man.

I have had similar problems lately. This should do the trick.

Good luck.

Reply With Quote
  #7  
Old 01-08-2005, 01:25 PM
filuren filuren is offline
View Beta Profile
Newbie
 
Join Date: Dec 2004
Posts: 13
I got ERROR 404 when downloading. Can you update the latest? Thanks!

[/usr/src]# wget http://dominia.org/djao/limit/mod_l...onn-0.04.tar.gz
--01:24:31-- http://dominia.org/djao/limit/mod_l...onn-0.04.tar.gz
=> `mod_l...onn-0.04.tar.gz'
Resolving dominia.org... done.
Connecting to dominia.org[18.208.0.43]:80... connected.
HTTP request sent, awaiting response... 404 Not Found
01:24:31 ERROR 404: Not Found.

Reply With Quote
  #8  
Old 01-08-2005, 06:59 PM
Blueheaven Blueheaven is offline
View Beta Profile
Web Hosting Evangelist
 
Join Date: Apr 2004
Posts: 465
The creator david, has updated the link, (not me)http://dominia.org/djao/limit/contri..._limitipconn.c

I dont think this will come out as a full url so right mouse click copy shortcut and then

wget url

Reply With Quote
  #9  
Old 01-08-2005, 11:03 PM
filuren filuren is offline
View Beta Profile
Newbie
 
Join Date: Dec 2004
Posts: 13
how is the setting i should use to limit zip files download? most of my sites anime and video files are in zipped.

Reply With Quote
  #10  
Old 02-03-2005, 05:29 PM
hostchamp hostchamp is offline
View Beta Profile
Web Hosting Master
 
Join Date: Aug 2002
Posts: 634
Someday i ll need to use it.
Thanks

Reply With Quote
  #11  
Old 02-03-2005, 05:50 PM
superprogram superprogram is offline
View Beta Profile
Web Hosting Master
 
Join Date: Dec 2003
Posts: 876
Blueheaven, that really looks great
What is the logic you are using here?

__________________
Primary email: advanced.programmer@gmail.com .. MSN/Email: superprg@hotmail.com
AIM: superprg

Reply With Quote
  #12  
Old 02-22-2005, 01:50 PM
justbenice justbenice is offline
View Beta Profile
Web Hosting Guru
 
Join Date: Feb 2004
Posts: 322
i cant make it work with my wma and wmv files

Reply With Quote
  #13  
Old 02-22-2005, 02:49 PM
justbenice justbenice is offline
View Beta Profile
Web Hosting Guru
 
Join Date: Feb 2004
Posts: 322
ok , do this trick
<IfModule mod_limitipconn.c>
<Location />
MaxConnPerIP 3
NoIPLimit image/*
</Location>
</IfModule>
and i got this work . Very cool apache mod .

Reply With Quote
  #14  
Old 02-24-2005, 07:46 AM
justbenice justbenice is offline
View Beta Profile
Web Hosting Guru
 
Join Date: Feb 2004
Posts: 322
And after 2 day of using this mod , i found out a very very big problem . Some users who have same ip class and netmask like aol will be all limit at 3 connection . Anyway we can fix this ?

Reply With Quote
  #15  
Old 02-24-2005, 09:22 AM
Blueheaven Blueheaven is offline
View Beta Profile
Web Hosting Evangelist
 
Join Date: Apr 2004
Posts: 465
what percentage of people are on aol?

Limiting ip's seems to be really only good if you have tons of traffic, like if you have too much traffic, that it slows your webpages down.

for example if I don't use this mod, my webpages takes 10* longer to load

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement: