Skip to content

Commit 5771eb2

Browse files
committed
feat(Dockerfile): enhance fail2ban setup with comprehensive filter configuration and permissions
- Add wildcard pattern to copy all filter configurations - Set permissions for all filter and action configurations - Create required directories and files for fail2ban feat(fail2ban): add new filters for probing and request flood detection - Introduce nginx-probing.conf to detect unauthorized probing attempts - Introduce nginx-request-flood.conf to detect request flooding feat(jail.local): configure new fail2ban jails for enhanced security - Add nginx-probing jail to monitor probing attempts - Add nginx-request-flood jail to monitor request flooding - Set findtime, maxretry, and bantime for new jails
1 parent d3da8a6 commit 5771eb2

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

src/Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,22 @@ COPY src/docker_scripts/fetch_cloudflare_ips.sh /usr/local/bin/
5252
COPY src/docker_scripts/update_cloudflare_ips.sh /usr/local/bin/
5353
COPY src/docker_scripts/startup.sh /usr/local/bin/
5454

55-
# Fail2ban configuration
55+
# Fail2ban configuration with comprehensive filter setup
5656
RUN mkdir -p /etc/fail2ban/action.d \
5757
&& mkdir -p /etc/fail2ban/filter.d \
5858
&& mkdir -p /etc/nginx/conf.d/banned \
5959
&& mkdir -p /var/run/fail2ban
6060

61-
COPY src/fail2ban/jail.local /etc/fail2ban/jail.local
62-
COPY src/fail2ban/filter.d/nginx-http-auth-proxma.conf /etc/fail2ban/filter.d/
61+
# Copy all filter configurations using wildcard pattern
62+
COPY src/fail2ban/filter.d/*.conf /etc/fail2ban/filter.d/
6363
COPY src/fail2ban/action.d/nginx-deny.conf /etc/fail2ban/action.d/
64+
COPY src/fail2ban/jail.local /etc/fail2ban/
6465

66+
# Set permissions and create required files
6567
RUN chmod 644 /etc/fail2ban/jail.local \
66-
&& chmod 644 /etc/fail2ban/filter.d/nginx-http-auth-proxma.conf \
67-
&& chmod 644 /etc/fail2ban/action.d/nginx-deny.conf \
68+
&& chmod -R 644 /etc/fail2ban/filter.d/* \
69+
&& chmod 644 /etc/fail2ban/action.d/* \
70+
&& mkdir -p /etc/nginx/conf.d/banned \
6871
&& touch /etc/nginx/conf.d/banned/banned_ips.conf \
6972
&& chmod 644 /etc/nginx/conf.d/banned/banned_ips.conf
7073

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Definition]
2+
failregex = ^<HOST>.*"GET .*HTTP.*" (403|404) \d+
3+
^<HOST>.*"(HEAD|OPTIONS) \/.*HTTP.*
4+
^<HOST>.*"\/\.git\/.*
5+
^<HOST>.*"\/\.env.*
6+
^<HOST>.*"\/wp-includes.*
7+
ignoreregex =
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[Definition]
2+
failregex = ^<HOST> -.*-.*$
3+
datepattern = %%d/%%b/%%Y:%%H:%%M:%%S

src/fail2ban/jail.local

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,21 @@ port = http,https
4343
enabled = true
4444
filter = nginx-botsearch
4545
logpath = /var/proxma/logs/nginx_access.log
46+
port = http,https
47+
48+
[nginx-probing]
49+
enabled = true
50+
filter = nginx-probing
51+
logpath = /var/proxma/logs/nginx_access.log
52+
findtime = 2m
53+
maxretry = 5
54+
port = http,https
55+
56+
[nginx-request-flood]
57+
enabled = true
58+
filter = nginx-request-flood
59+
logpath = /var/proxma/logs/nginx_access.log
60+
findtime = 60
61+
maxretry = 100
62+
bantime = 3600
4663
port = http,https

0 commit comments

Comments
 (0)