⚠️ Important: Always allow SSH access before enabling UFW to prevent being locked out of your server!
sudo apt install ufw -y
Install Uncomplicated Firewall if it's not already on your system
sudo ufw status
Check if UFW firewall is active
sudo ufw allow ssh
Allow SSH connections to prevent being locked out of your server
sudo ufw allow 'Apache'
Allow HTTP and HTTPS traffic through firewall
sudo ufw enable
Activate the firewall with all configured rules
sudo ufw allow 80/tcp && sudo ufw allow 443/tcp
Manually allow HTTP (port 80) and HTTPS (port 443) traffic