Ban that bandwidth slurper

Angel, the machine that runs (among other sites) is being rather slow. On investigation of my logs, it appears that that’s quite possibly because it’s being hammered by people. I deleted my log and then waited an hour to see if I was being hit a lot (the log was 200MB! in less than an hour!) and then pulled out the 5 most persistent offenders with

cut -d" " -f1 /var/log/apache2/ | sort | uniq -c | sort -n | tail -5

which gave me


Those last two are a bit high, I think; two thousand hits in an hour? I mean, I appreciate all you people reading the good word of the Langridge, but I’m not that good a writer. So, they get banned, which is nice and easy. Following Mark Pilgrim’s explanation, I added the following lines to .htaccess:

# all your DoS are belong to us. Ban ban ban.
RewriteCond %{REMOTE_ADDR} ^$
RewriteRule .* - [F,L]
RewriteCond %{REMOTE_ADDR} ^$
RewriteRule .* - [F,L]

and…no more hits from those IPs. Beware, people sucking down my bandwidth: I have plenty of room in .htaccess for more of those lines.

I'm currently available for hire, to help you plan, architect, and build new systems, and for technical writing and articles. You can take a look at some projects I've worked on and some of my writing. If you'd like to talk about your upcoming project, do get in touch.

More in the discussion (powered by webmentions)

  • (no mentions, yet.)