Dear forum members
I use NGINX as reverse proxy to protect my Gitea dashboard on a VServer. SSL with Let's encrypt went fine and I installed fail2ban to block IP-addresses when a user tries to log on more than 5 times with the wrong username / PW combination.
And fail2ban works fine. I'm using the ufw-multiport.conf from Xela in actions.d and the firewall rules look like this, once I provoke a ban by giving false credentials:
So the first rule is the new deny rule for my IP.
But unfortunately the authentication session stays open. I can provide more false credentials and my attempts are logged in the fail2ban.log:
Only when I use another browser to open the gitea dashboard or if I restart the browser that I used before, the ban is successful.
So obviously the open authentication session outrules the firewall configuration. I'm now searching for a ban action that I can add to my gitea configuration in .../jail.d/jail.local that will force nginx to drop the session immediately and force the site to reload into emptyness.
I thought the nginx-block-map-conf in actions.d could maybe help, but I didn't find a usage example.
Any incoming ideas will be greatly appreciated.
Kind regards, MisterIX.
PS. Oh, aus reiner Gewohnheit habe ich auf Englisch gepostet. Ich hoffe, dass ist nicht so schlimm, sorry.
I use NGINX as reverse proxy to protect my Gitea dashboard on a VServer. SSL with Let's encrypt went fine and I installed fail2ban to block IP-addresses when a user tries to log on more than 5 times with the wrong username / PW combination.
And fail2ban works fine. I'm using the ufw-multiport.conf from Xela in actions.d and the firewall rules look like this, once I provoke a ban by giving false credentials:
Code:
root@********:/var/log# ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] 80,443/tcp DENY IN 177.191.157.126 (log)
[ 2] 32221 ALLOW IN Anywhere
[ 3] 80/tcp ALLOW IN Anywhere
[ 4] 443 ALLOW IN Anywhere
[ 5] 32221 (v6) ALLOW IN Anywhere (v6)
[ 6] 80/tcp (v6) ALLOW IN Anywhere (v6)
[ 7] 443 (v6) ALLOW IN Anywhere (v6)
So the first rule is the new deny rule for my IP.
But unfortunately the authentication session stays open. I can provide more false credentials and my attempts are logged in the fail2ban.log:
Code:
2022-09-18 11:15:31,970 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:31
2022-09-18 11:15:34,692 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:34
2022-09-18 11:15:37,759 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:37
2022-09-18 11:15:40,560 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:40
2022-09-18 11:15:43,265 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:43
2022-09-18 11:15:43,320 fail2ban.actions [15244]: NOTICE [gitea] Ban 177.191.157.126
2022-09-18 11:15:49,663 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:49
2022-09-18 11:15:52,699 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:52
2022-09-18 11:15:55,404 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:15:55
2022-09-18 11:16:01,314 fail2ban.filter [15244]: INFO [gitea] Found 177.191.157.126 - 2022-09-18 11:16:00
2022-09-18 11:30:43,305 fail2ban.actions [15244]: NOTICE [gitea] Unban 177.191.157.126
Only when I use another browser to open the gitea dashboard or if I restart the browser that I used before, the ban is successful.
So obviously the open authentication session outrules the firewall configuration. I'm now searching for a ban action that I can add to my gitea configuration in .../jail.d/jail.local that will force nginx to drop the session immediately and force the site to reload into emptyness.
Code:
[gitea]
enabled = true
filter = gitea
logpath = /var/lib/gitea/log/gitea.log
maxretry = 5
findtime = 600
bantime = 900
action = ufw-multiport[port="80,443", protocol=tcp]
I thought the nginx-block-map-conf in actions.d could maybe help, but I didn't find a usage example.
Any incoming ideas will be greatly appreciated.
Kind regards, MisterIX.
PS. Oh, aus reiner Gewohnheit habe ich auf Englisch gepostet. Ich hoffe, dass ist nicht so schlimm, sorry.
Last edited: