Install UFW
UFW is preinstalled on most images. If it is missing, install it with:Set default rules
Block all incoming traffic by default and allow all outgoing traffic. This is the safe baseline.Allow the ports you need
1
Allow SSH first
2
Allow web traffic if you run a website
3
Allow any custom ports your app needs
4
Enable the firewall
