Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm struggling to match Fail2Ban's failregex on Apache logs using only the HTTP return codes. The log format I'm using is below and in that example it's the field showing "200". As long as the other fields (in that format) can be anything else then it's just that field I'm interested in.

66-121-89-14.domain.com - - [14/Apr/2011:14:47:05 +0100] "GET /city/index.html HTTP/1.1" 200 2577 "http://www.domain.com/referrer/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"

I think I need something like this.

failregex = ^(?P<host>\S*).*("-" "-"| 502 | 500 | 417 | 416 | 415 | 414 | 413 | 412 | 405 | 403 |

Can a regex aficionado please help ?

share|improve this question
up vote 1 down vote accepted

How does this do ?

<HOST>.*\" (500|502|...)

share|improve this answer
    
Great, thanks very much. – Jonathan Ross Apr 14 '11 at 15:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.