Based on this repository I want to use fail2ban filters to analyze my nginx logs and ban suspicious requests and IPs.
On my server I'm using a custom log format for nginx. Due to the fact that I'm hosting multiple sites the log files have the following structure.
log_format custom_format '$server_name $remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" "$gzip_ratio"'
What will generate a log entry like this:
www.example.com 62.210.129.246 - - [24/Aug/2018:11:07:46 +0200] "POST /wp-login.php HTTP/1.1" 301 185 "http://example.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" "-"
Due to the fact, that I'm adding the server_name in front of remote_addr the <HOST>
regex-group (fail2ban resolves this to (?:::f{4,6}:)?(?P<host>\S+))
wont match. Not sure how I should modify the regex to match my log format.
Any ideas?