Wednesday, June 1, 2011

Blocking Download Accelerators - Apache

Download Accelerators (or Download Managers) are not that bad if they limit their connections to a handful, but I've noticed that some users are using well over 100 connections to download a mere 2MB file. I have some sympathy, as they are usually in far away countries that probably have limited bandwidth to my server. That said, it is only a 2MB file, and is mirrored on and elsewhere.

Now, you could limit the number of connections per IP, and perhaps that is preferable for some. However, I decided to utilize Apaches mod_rewrite to quickly fix up this problem. To get to the point, simply add something like so to your .htaccess (after confirming mod_rewrite is loaded or was linked with Apache via 'httpd -l'):

RewriteCond %{HTTP:Range} !^$
RewriteRule ^files/.+$ - [F,L]

RegEx, how beautiful - not :). What is important to know about the above example is that affected downloads are in the subdirectory 'files'. So, adjust that subdirectory as needed. I tried out a popular download accelerator, and confirmed this works great.

What this does is prevent the download accelerators from downloading parts of a file, thus making them useless on the site. It does have the side-effect of causing downloads initiated with download accelerators to halt at whatever % the first connection retrieved, but users should be able to figure out what's up.

If mod_rewrite is available, it was surely turned on in the configuration file, but you can add 'RewriteEngine on' above this if you like.

If you believe you have a better solution, feel free to comment.


  1. I used same. My previous site got hammered down by download acceleratos/managers.

    Two users used *un-named" managers and opened thousands and thousands of connections and eventually CPU load was too high and provider had no choice than close/suspend my account..

    IMO: peoples who use those apps, should think that how about server i'm downloading. Can it handle that? And near all thinks (this comment is based on my log files..), i don't care what happens, it's "faster" for me..

  2. Agreed, there needs to be a massive public education campaign to let people know the real deal on these download accelerators. Further, with today's high speed broadband connections they really don't help much. It is just that a few consumers will want their downloads to be as fast as possible, so use whatever claims to do that even if their actual gain is negligible.

    I believe that these download managers is what killed my previous VPS. I migrated to a dedicated server, as I needed to anyway, but had I enforced this then I am sure the VPS wouldn't have crashed so hard (the 512MB of RAM allocated to it would fill up and since swapping was disallowed, it simply crashed when new memory couldn't be allocated).