VPS_DOCS

Firewall Configuration

A firewall is essential for controlling network traffic. We'll use UFW (Uncomplicated Firewall).

01Install UFW

Ensure UFW is installed (usually default on Ubuntu).

Terminal
sudo apt install ufw -y

02Configure Rules

Allow necessary ports. CRITICAL: Allow your custom SSH port first.

Terminal
# Allow custom SSH port (CRITICAL)
sudo ufw allow 2222/tcp

# Allow standard web traffic
sudo ufw allow 80/tcp    # HTTP
sudo ufw allow 443/tcp   # HTTPS

# Optional: Alternate ports
sudo ufw allow 8080/tcp  # HTTP Alt
sudo ufw allow 8443/tcp  # HTTPS Alt

03Enable Firewall

Activate the firewall rules. Confirm with 'y' when prompted.

Terminal
sudo ufw enable
# Confirm with 'y'

04Verify Status

Check that your rules are active and correct.

Terminal
sudo ufw status verbose