DEV Community

Discussion on: How to Protect Your Server From Hackers

Collapse
 
glennmen profile image
Glenn Carremans

Great post! This is also my default workflow when I setup a new VPS.

Just a couple of tips:

Just like SSH has an alternative syntax you can do the same for port 80 and 443.
ufw allow http & ufw allow https

You can also run the command: ufw app list
This will show a list of available applications that you can add to your UFW firewall so that if the port config has changed for example this will also be updated in your UFW.
My UFW rules:

To                         Action      From
--                         ------      ----
Nginx Full                 ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
Nginx Full (v6)            ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)

If you want your server to accept IPv6 you will need to enable this in your UFW config.

sudo nano /etc/default/ufw

And then change this: IPV6=yes
UFW reboot required after this change of course.

For fail2ban I have 3 jails enabled: sshd, sshd-ddos and nginx-botsearch
Current status for my sshd jail:

Status for the jail: sshd
|- Filter
|  |- Currently failed: 2
|  |- Total failed: 28259
|  `- File list:    /var/log/auth.log
`- Actions
   |- Currently banned: 0
   |- Total banned: 78
   `- Banned IP list:
Collapse
 
vkolesov profile image
Vitaliy Kolesov • Edited

Thanks to you, I pay attention to sshd-ddos!

In front of the nginx on my server I have traefik inside the docker container. I will try to research how to make them work together.