Skip to content

Commit 8921cd1

Browse files
author
Daniel
committed
Update fail2ban regex pattern to include more HTTP methods and fix formating for domain logs
1 parent 0119cf7 commit 8921cd1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,11 @@ def generate_filter_config(config):
354354
"""
355355
# Create a regex pattern that matches the status codes
356356
status_codes_pattern = '|'.join(config.status_codes.split(','))
357+
358+
# Example fail regex: failregex = ^"?<HOST> - - \[.*?\] "(GET|POST|HEAD|PUT|DELETE) .*? HTTP/.*?" (401|403|404|500)
357359

358360
return f"""[Definition]
359-
failregex = ^<HOST> -.*"(GET|POST).*" [{status_codes_pattern}]
361+
failregex = ^"?<HOST> - - \[.*?\] "(GET|POST|HEAD|PUT|DELETE) .*? HTTP/.*?" ({status_codes_pattern})
360362
ignoreregex =
361363
"""
362364

0 commit comments

Comments
 (0)