Enable a website firewall to increase website security

It’s so satisfying and much cheaper to host your own websites on a self managed barebones vps. But if you’re going to host your own websites then you will need to have a firewall running to protect your website from hackers.

Luckily UFW, the default firewall on Linux distributions makes the process of enabling a firewall simple.

What is a website firewall?

A website firewall is a security solution designed to monitor, filter, and block malicious traffic to a website. It helps protect against various online threats, such as hacking attempts, DDoS attacks, and other types of cyber threats by analyzing and filtering incoming web traffic.

What is UFW?

Uncomplicated Firewall (UFW) is a user-friendly command-line interface for managing iptables, which is the default firewall management tool in many Linux distributions. UFW is designed to simplify the process of configuring a firewall by providing a straightforward syntax.

Enable Firewall

sudo ufw enable

Disable Firewall

sudo ufw disable


See what rules are in place

sudo ufw status

Get a bit more information

sudo ufw status verbose

Allow range of ip’s

sudo ufw allow proto tcp from to any port 22

Allow range of ip’s with a dry run

sudo ufw --dry-run allow proto tcp from to any port 22

Reset all UFW rules

Start from the default ufw configuring your rules

sudo ufw reset

allow access to special port

ufw allow from to any port 7080

To view all blocked threats using Uncomplicated Firewall (ufw), you can check the firewall logs. Use the following command in the terminal:

sudo ufw statusgrep BLOCK

This command filters the status output to show only the blocked entries, providing information about blocked threats or unauthorized access attempts.

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.