LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
-->
 
Search this Thread
Old 06-20-2008, 12:58 AM   #1
Sagebrush Gardener
LQ Newbie
 
Registered: Mar 2007
Posts: 29

Rep: Reputation: 15
Misconfigured client uses all available Apache connections


Hello,

Our Apache web server is heavily used for downloads of large (100MB+) files.

Occasionally - every couple of months or so - we get a user who appears to have misconfigured download software. It attempts to download one of these large files and opens multiple simultaneous connections until all available Apache connections are used up. When this happens no one else can connect. In one case, our logs show that this denial of service lasted for 15 hours.

Restarting the web service does not help, since within two minutes all available connections are full again. MaxClients is currently set to 256. That is the most I can set this to without recompiling Apache but I don't think that increasing this will help because the client appears to use up all available connections no matter how many there are.

I have also tried installing mod_limitipconn.c - see http://dominia.org/djao/limitipconn.html for details. This module sends the user a 503 error message when exceeding a defined limit (currently set to 4). However this error message itself appears to use up a connection. So a client that keeps blindly making requests regardless of the error messages still uses up all available connections.

At this time the only way I have found to mitigate the problem is to manually block all connections from the user's IP address with iptables. This of course requires that I am aware of the problem when it happens and can log in to block the user before he brings down the server.

Do you have any suggestions to fix this problem?

Here are a few lines from the log file. This goes on for over 60,000 attempts!

222.66.100.122 222.66.100.122 - [28/May/2008:22:38:30 -0700] "GET /syn_dl/OKsGhzaOKMgXpczdaoKdZzESG/fpga922.exe HTTP/1.1" 503 328 "http://cct.me.ntut.edu.tw/chchting/aiahtm/display2007-2.html" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"
222.66.100.122 222.66.100.122 - [28/May/2008:22:38:30 -0700] "GET /syn_dl/OKsGhzaOKMgXpczdaoKdZzESG/fpga922.exe HTTP/1.1" 503 328 "http://cct.me.ntut.edu.tw/chchting/aiahtm/display2007-2.html" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"
222.66.100.122 222.66.100.122 - [28/May/2008:22:38:30 -0700] "GET /syn_dl/OKsGhzaOKMgXpczdaoKdZzESG/fpga922.exe HTTP/1.1" 503 328 "http://cct.me.ntut.edu.tw/chchting/aiahtm/display2007-2.html" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"
222.66.100.122 222.66.100.122 - [28/May/2008:22:38:32 -0700] "GET /syn_dl/OKsGhzaOKMgXpczdaoKdZzESG/fpga922.exe HTTP/1.1" 503 328 "http://cct.me.ntut.edu.tw/chchting/aiahtm/display2007-2.html" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"
222.66.100.122 222.66.100.122 - [28/May/2008:22:38:32 -0700] "GET /syn_dl/OKsGhzaOKMgXpczdaoKdZzESG/fpga922.exe HTTP/1.1" 503 328 "http://cct.me.ntut.edu.tw/chchting/aiahtm/display2007-2.html" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"
222.66.100.122 222.66.100.122 - [28/May/2008:22:38:32 -0700] "GET /syn_dl/OKsGhzaOKMgXpczdaoKdZzESG/fpga922.exe HTTP/1.1" 503 328 "http://cct.me.ntut.edu.tw/chchting/aiahtm/display2007-2.html" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"
222.66.100.122 222.66.100.122 - [28/May/2008:22:38:32 -0700] "GET /syn_dl/OKsGhzaOKMgXpczdaoKdZzESG/fpga922.exe HTTP/1.1" 503 328 "http://cct.me.ntut.edu.tw/chchting/aiahtm/display2007-2.html" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"


Thank you.

Sorry, I forgot to mention...

Server: Apache/1.3.33 (Unix) mod_ssl/2.8.22 OpenSSL/0.9.7g

Last edited by Sagebrush Gardener; 06-20-2008 at 01:01 AM. Reason: added server version
 
Old 06-20-2008, 01:53 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 56
The same IP each time? I'd just permanently firewall block the client and be done with it.
 
Old 06-20-2008, 08:34 AM   #3
Sagebrush Gardener
LQ Newbie
 
Registered: Mar 2007
Posts: 29

Original Poster
Rep: Reputation: 15
No, it usually comes from different locations, often from China. I don't know how it happens but there seem to be a lot of these resource hogs out there. One day recently, mod_limitipconn blocked over 364,000 requests! mod_limitipconn is helping some, but once in a while it still gets overwhelmed.
 
Old 06-20-2008, 12:23 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 56
I see. There are plenty of DoS attacks out there. Sometimes the best you can do is just block the host, or IP range.

You can rate limit that IP or IP range, Consider also fail2ban: http://www.fail2ban.org/wiki/index.php/Main_Page
 
Old 06-20-2008, 12:29 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 20,970
Blog Entries: 44

Rep: Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226
And a more complete overview of solutions can be found here: http://www.linuxquestions.org/questi...tempts-340366/
 
Old 06-20-2008, 06:12 PM   #6
kenoshi
Member
 
Registered: Sep 2007
Location: SF Bay Area, CA
Distribution: CentOS, SLES 10+, RHEL 3+, Debian Sarge
Posts: 159

Rep: Reputation: 31
You should think about doing this on layer 3. Most firewalls and commercial load balancers easily do this for you with built in rate/connection limiting/DDOS functions. Some routers/switches can do this as well.

If you use iptables and only have one download server, fail2ban like Mr. C suggested works great.
 
Old 06-23-2008, 10:00 PM   #7
Sagebrush Gardener
LQ Newbie
 
Registered: Mar 2007
Posts: 29

Original Poster
Rep: Reputation: 15
Thank you for the suggestions everyone. I have installed fail2ban and it seems to be working well so far. I have set it to automatically block IP addresses that generate more than 100 excessive connection warnings in 10 minutes. 15 IP addresses have been blocked since yesterday. Interestingly they are all from China and all are using IE 5 or IE 6 according to the user agent string. I don't understand it. Is there something that would make IE open excessive connections when connecting from China? Anyway I am happy that I now have a tool to handle the problem. Thanks again.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to see VMWare client connections through local IPTables SlowCoder Linux - Security 0 05-09-2008 02:45 PM
dns works on server, refuses client connections mfleonhardt Linux - Networking 2 01-20-2008 08:19 PM
Had apache working, then set up vsftpd, now apache is refusing my connections beetle_boy66 Linux - Newbie 4 01-25-2006 09:57 PM
FTP client for multiple connections CodeZero Linux - Software 1 07-07-2004 12:48 PM
Apache/SSL - works with Windows client but not Linux client RickHDYoung Linux - Security 1 07-01-2004 05:02 PM


All times are GMT -5. The time now is 04:54 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration