Set up UFW
First, connect to your VPS with SSH.1
Install UFW
2
Block incoming, allow outgoing
3
Allow SSH
sudo ufw allow 2222/tcp.4
Allow what your server needs
For a website:
5
Turn it on
y to confirm.Manage rules
AlmaLinux, Rocky Linux or Fedora?
These usefirewalld instead of UFW:
Firewall tab in the Client Area
You can also attach a firewall from the Firewall tab on your server panel. It filters traffic before it reaches your server, and one firewall can protect several of your servers at once. If you use it as well as UFW, a connection must be allowed by both.