File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,4 +175,38 @@ JELLYSEERR_JAIL_CONF
175175 sed -i " s|^# chain|chain|" /etc/fail2ban/jail.d/jellyseerr.local
176176fi
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+
178212fail2ban-server -f --logtarget stderr --loglevel info
You can’t perform that action at this time.
0 commit comments