Les attaques w00tw00t sur votre serveur peuvent être très gênantes et utilisent des ressources inutilement. Il est pourtant très simple de les bloquer grâce à fail2ban.
Si vous n’avez pas encore fail2ban, empressez vous d’installer ce logiciel fantastique (
apt-getinstall fail2ban sous Debian / Ubuntu).
La première étape consiste à créer un filtre pour les logs nginx, commencez donc par créer un fichier /etc/fail2ban/filter.d/nginx-w00tw00t.conf avec le contenu suivant :
Editez ensuite votre fichier /etc/fail2ban/jail.conf et ajoutez
Shell
1
2
3
4
5
6
7
8
[nginx-w00tw00t]
enabled=true
port=http
filter=nginx-w00tw00t
logpath=/var/log/nginx/access.log
maxretry=1
bantime=172800
Avec ces paramètres, fail2ban va bloquer chaque robot pendant 2 jours.
N’hésitez pas à tester votre configuration à l’aide de la commande fail2ban-regex :
fail2ban-regex/var/log/nginx/access.log/etc/fail2ban/filter.d/nginx-w00tw00t.conf .
Vous pouvez consulter le résultat des bans dans le fichier /var/log/fail2ban.log.
Les attaques DDOS sur votre serveur peuvent être très gênantes et utilisent des ressources inutilement. Il est pourtant très simple de les bloquer grâce à fail2ban.
Si vous n’avez pas encore fail2ban, empressez vous d’installer ce logiciel fantastique (
apt-getinstall fail2ban sous Debian / Ubuntu).
La première étape consiste à créer un filtre pour les logs nginx, commencez donc par créer un fichier /etc/fail2ban/filter.d/nginx-dos.conf avec le contenu suivant :
Shell
1
2
3
4
5
6
# fail2ban filter configuration for nginx
[Definition]
failregex=^<HOST>-.*"(GET|POST).*HTTP.*"$
ignoreregex=
Editez ensuite votre fichier /etc/fail2ban/jail.conf et ajoutez
Shell
1
2
3
4
5
6
7
8
9
[nginx-dos]
enabled=true
port=http
filter=nginx-dos
logpath=/var/log/nginx/access.log
findtime=30
bantime=172800
maxretry=120
Avec ces paramètres, fail2ban va bloquer tous les robots qui lancent plus de 120 requêtes par tranche de 30 secondes pendant 2 jours. Par définition, un humain ne peut pas avoir autant de requêtes sur un laps de temps aussi court.
N’hésitez pas à tester votre configuration à l’aide de la commande fail2ban-regex :
fail2ban-regex/var/log/nginx/access.log/etc/fail2ban/filter.d/nginx-dos.conf .
Vous pouvez consulter le résultat des bans dans le fichier /var/log/fail2ban.log.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Durée
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.