Spambots clutter my log file [Django]

I have a nice and beautiful Django site, but I noticed that my file error.logbecame huge, more than 150 MB after several months of life. It turns out that a bunch of spam bots look for known URL vulnerabilities (or something else) and fall into a bunch of subdirectories, such as http://mysite.com/ieor http://mysite.com/~admin.phpetc.

Since Django uses URL rewriting, it looks for patterns to match these requests, which throws an exception TemplateDoesNotExistand then a 500 message (Django does this, not me). I have debugging turned off, so they only receive a general 500 message, but it fills my logs very quickly.

Is there any way to disable this behavior? Or maybe just block IP to do this?

+3
source share
8 answers

Um, maybe use logrotate to periodically rotate and compress logs, if not already done.

+6
source

"Is there a way to disable this behavior?" - 500 is absolutely necessary. A journal entry is also required.

"Or maybe just block the IP?" - We do not wish.

Everyone has this problem. Almost everyone uses Apache log rotation . All others use either OS rotation or minimize their own.

+3
source

UserAgent, DISALLOWED_USER_AGENT. :

DISALLOWED_USER_AGENTS = (
    re.compile(r'Java'),
    re.compile(r'gigamega'),
    re.compile(r'litefinder'),
)

. Django docs.

+3

Django 404, 500, URL- URLConf.

http://docs.djangoproject.com/en/dev/topics/http/urls/#handler404

404:

404 - , - : 404.html . 404 404.

+2

:

  • , ,

! !

0

catch-all urls " ​​" ? , 500 .

0

""? URL , . , : -)

0
  • , 404, 500. 500 , - URL- . .

  • We have a similar problem. Since we are running Apache / mod_python, I decided to deal with it in .htaccess with the mod_rewrite rules. I periodically look through the magazines and add a few templates to my go to hell list. They are all overwritten to deliver a 1x1 pixel gif file. There is no 404s tsunami to clutter my log analysis, and it puts a minimal burden on Django and Apache.

You cannot make these holes go away, so all you can do is minimize their impact on your system and continue to live.

0
source

All Articles