Web Hosting & VPS Tips

Unleash Your Server Potential with Expert Insights

Hosting provided by: Cloudways
Free to Try! Up to 40% Off!

Category: VPS Setup

Secure Nginx with Fail2ban on Ubuntu—install with
apt install nginx fail2ban
then create /etc/fail2ban/jail d/nginx-auth conf with
nano /etc/fail2ban/jail.d/nginx-auth.conf
:
[nginx-http-auth]\nenabled = true\nport = 80,443\nfilter = nginx-http-auth\nlogpath = /var/log/nginx/error.log\nmaxretry = 5\nbantime = 3600
Restart with
systemctl restart fail2ban
open ports with
ufw allow 80 && ufw allow 443
Enable Nginx auth logging in /etc/nginx/nginx conf with error_log /var/log/nginx/error log warn; On Hetzner test with failed logins—check
fail2ban-client status nginx-http-auth
for bans ensuring phpMyAdmin and web uptime with 1-hour blocks

Back to All Tips