Security bash Intermediate

UFW Firewall Setup

Opinionated UFW configuration for a typical web server: SSH, HTTP, HTTPS only.

bash
#!/bin/bash
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
ufw status verbose

Prerequisites

  • ufw
  • Ubuntu/Debian

Pro Tips

  • → Change SSH port and allow new port before denying 22.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
bash
Level
Intermediate
Read time
2 min
Published
Jan 2025
License
Commercial License

Newsletter

New modules every week, directly to your inbox.