Open cjmling opened 5 years ago
You might want to put extra config about ssh in jail.local
and set enabled to false because its enabled by default in jail.conf
and putting that config in jail.local
with enabled false will disabled it as we don't need.
So it become
jail.local
[nginx-req-limit]
enabled = true
port = http,https
filter = nginx-req-limit
logpath = /var/log/nginx/access.log
maxretry = 6
findtime = 600
bantime = 7200
banaction = slack-notify
[ssh]
enabled = false
We can use fail2ban-regex <logfile> <filter>
to test the filter regex if its matching any existing log or not.
fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/sshd.conf
We can pass param from jail to banaction
example
banaction = slack-notify[findtime=60, another_param=whatever]
We want to send notification to slack about IP address which seems sending too much request to our server.
1. Install Fail2ban
apt install fail2ban -y
apt update
if it error/fails not able to fetch the deb url.2. Create a
jail.local
file in/etc/fail2ban/
folderjail.local
filter = nginx-req-limit
we will create this filter soonbanaction = slack-notify
we will create this banaction soon3. create
nginx-req-limit.conf
file in/etc/fail2ban/filter.d/
foldernginx-req-limit.conf
Regex Credit: https://gist.github.com/Swop/6049297
4. Create
slack-notify.conf
in/etc/fail2ban/action.d/
folderslack-notify.conf
credit : https://github.com/coleturner/fail2ban-slack-action
5. run
service fail2ban restart
to start the service and should get notification to slack that it get startedIf you doesn't get notification then
service fail2ban status
to see if there was any error6. use
fail2ban-client status
orfail2ban-client status nginx-req-limit
to view its status