Skip to content

Commit 8cc9368

Browse files
committed
add support for gitea
Signed-off-by: Simon L. <szaimen@e.mail.de>
1 parent 58843dc commit 8cc9368

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

start.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,38 @@ JELLYSEERR_JAIL_CONF
175175
sed -i "s|^# chain|chain|" /etc/fail2ban/jail.d/jellyseerr.local
176176
fi
177177

178+
if [ -d /gitea ]; then
179+
echo "Configuring gitea for logs"
180+
# Gitea conf
181+
cat << GITEA_CONF > /etc/fail2ban/filter.d/gitea.conf
182+
[INCLUDES]
183+
before = common.conf
184+
185+
[Definition]
186+
failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
187+
ignoreregex =
188+
GITEA_CONF
189+
190+
# Gitea jail
191+
cat << GITEA_JAIL_CONF > /etc/fail2ban/jail.d/gitea-host.local
192+
[gitea-host]
193+
enabled = true
194+
port = 80,443,3000,2222
195+
protocol = tcp,udp
196+
filter = gitea
197+
banaction = %(banaction_allports)s
198+
maxretry = 3
199+
bantime = 14400
200+
findtime = 14400
201+
logpath = /gitea/gitea.log
202+
# chain=DOCKER-USER
203+
ignoreip = 127.0.0.1/8 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8 fd00::/8 ::1
204+
GITEA_JAIL_CONF
205+
206+
rm -f /etc/fail2ban/jail.d/gitea.local
207+
cp /etc/fail2ban/jail.d/gitea-host.local /etc/fail2ban/jail.d/gitea.local
208+
sed -i "s|\[gitea-host\]|\[gitea\]|" /etc/fail2ban/jail.d/gitea.local
209+
sed -i "s|^# chain|chain|" /etc/fail2ban/jail.d/gitea.local
210+
fi
211+
178212
fail2ban-server -f --logtarget stderr --loglevel info

0 commit comments

Comments
 (0)