From time to time, I'm visited by "leechers" downloading an entire site (~2 GB) within a few hours, while the average visitor stays far below 50 MB. I'd like to setup a "byte-limit" per visitor (e.g. allowing max 100 MB per day and visitor).
I've tried mod_cband, which comes pretty close to my goal. Unfortunately I've managed only to establish a quote per VHost – i.e. if the quota was hit, the entire VHost becomes blocked. mod_cband also can manage quotas per remote IP – but for that I'd need to know those IPs in advance, which I do not.
I've also looked into mod_evasive, which I already use in slightly different context. But this only lets me limit the number of requests, and doesn't take the "volume" (bytes transferred) into account.
Are there any "ready-to-use" solutions available? If I've missed something with mod_cband, hints are welcome as well. If a solution cannot be bound to a VHost (but would apply server-wide), that would be acceptable as well (though per VHost is preferred).
Note I do not want to limit the bandwith (i.e. speed), neither limit simultaneously requests per IP; this is not about bandwidth but against "copy-cats".
Edit: I've just found Apache::Quota which seems to do pretty much what I want. But it a) requires to have mod_perl
running (I'm not that familiar with Perl coding), and b) seems unmaintained (latest version is v0.04, dating back to 3/2007, and was intended for Apache 1.3 if I got that correctly).
Edit2: Solutions based on mod_security or iptables are welcome, too. So far, all I've found in this context was speed throtteling or limiting the amount of connections per remote IP, which is not what I'm after.
Edit3: Though I already found a solution for the underlying issue (see my answer below), I'm still interested in a solution to establish a "transfer quota per visitor and time", as described in my question – as my solution cannot be applied everywhere (see the "assumptions" described there).