From Fail2ban
Revision as of 09:36, 30 January 2009 by (Talk) (Added regex to ban repeted forbidden accesses)

Jump to: navigation, search

Apache HTTP Server is a free software/open source web server for Unix-like systems, Microsoft Windows, Novell NetWare and other operating systems. Apache is notable for playing a key role in the initial growth of the World Wide Web, and continues to be the most popular web server in use, serving as the de facto reference platform against which other web servers are designed and judged.

From Wikipedia, the free encyclopedia

  • [Sun Jan 28 11:55:32 2007] [error] [client] user myCoolUser: authentication failure for "/myPasswordedDir": Password Mismatch
  • [Tue Apr 10 15:39:26 2007] [error] [client x.x.x.x] Digest: user Username: password mismatch: /
  • [Tue Jan 27 15:32:40 2009] [error] [client] client denied by server configuration: /var/www/apache2-default/nonexistingpage.html


The regular expressions below are proposed failregex for this software. Multiple regular expressions for failregex will only work with a version of Fail2ban greater than or equal to 0.7.6.

The tag <HOST> in the regular expressions below is just an alias for (?:::f{4,6}:)?(?P<host>\S+). The replacement is done automatically by Fail2ban when adding the regular expression. At the moment, exactly one named group host or <HOST> tag must be present in each regular expression.

Please, before editing this section, propose your changes in the discussion page first.

Authentication failure (doesn't it match to many cases ?):

  • [[]client <HOST>[]] user .*(?:: authentication failure|not found|password mismatch)

Forbidden access:

* ^\[[^\]]*\]\s+\[error\]\s+\[client <HOST>\] client denied by server configuration:


If you don't have PHP service running or do not expect so many 'File does not exist' logging in Apache's error log, for attempts to log into some admin modus as shown below, you can also ban these IPs.

  • [Sat Mar 15 03:08:59 2008] [error] [client xyz.246.51.abc] File does not exist: /var/www/blabla/sqladmin/main.php
  • [Sat Mar 15 03:08:59 2008] [error] [client xyz.246.51.abc] File does not exist: /var/www/blabla/php/main.php
  • [Sat Mar 15 03:08:59 2008] [error] [client xyz.246.51.abc] File does not exist: /var/www/blabla/myadmin/main.php

This can be done by using the following regex in an extra Apache section in fail2ban.conf:

failregex = [[]client (?P<host>\S*)[]] File does not exist: .*\.php