DEV Community

Lulu
Lulu

Posted on

SafeLine WAF: The Ultimate Lightweight Web Application Firewall for Security

SafeLine WAF is a lightweight, yet highly secure Web Application Firewall (WAF) designed to fully protect your web applications from common attacks and exploits. Built on Nginx, it functions as a reverse proxy to intercept and analyze traffic before it reaches your web server.

Image description

How It Works:

Take a look at this simple web traffic flow: external users send requests that travel through the network and eventually reach your web server.
Image description
SafeLine sits as a reverse proxy, intercepting traffic before it hits your server. It thoroughly inspects the traffic for any malicious behavior, cleanses it, and then forwards the sanitized traffic to your server.
Image description

1. Installation

It's important to install SafeLine on a different machine than your web service. You'll need a Docker environment to proceed with the installation. Here's a quick demonstration of installing SafeLine on an Unraid system.

For an online installation, enter the following command:



bash -c "$(curl -fsSLk https://waf.chaitin.com/release/latest/setup.sh)"


Enter fullscreen mode Exit fullscreen mode

When prompted for an installation directory, press Enter to accept the default.

Since I'm using Unraid, I'll install it in the Docker directory for easier management:



/mnt/user/appdata/safeline


Enter fullscreen mode Exit fullscreen mode

Once the installation is complete, click the link https://<safeline-ip>:9443/ to access the console.

2. Getting Started

Click "Agree, Get Started" and enter the initial username and password, both of which are "admin."

Image description

You’ll find the interface clean and user-friendly.

Image description

2.1 Resetting Your Password

If you forget your password, don't worry. You can reset it easily by following these steps:

If you’re prompted with an incorrect password message, click "Forgot Password."

Image description

To reset the password, enter the following command:



docker exec safeline-mgt resetadmin


Enter fullscreen mode Exit fullscreen mode

After resetting, log in again, go to "System Settings," and change the account password.

Image description

Image description

2.2 Adding a Site

In this example, I’ve set up an Nginx server as the web site. Since SafeLine and Nginx (the protected web site) are on the same server and share the same IP address, make sure the port numbers you set don't conflict!

  • Enter the port number you’ll use to access the web page.
  • Fill in the upstream (the web site you want to protect). Image description

Once you’ve done this, the site will be successfully added! You can now access the web page through port 8082.

Image description

If you need HTTPS, you'll have to add your own certificate:

  • Upload the certificate and private key.
  • Check SSL and select your certificate.

Image description

This will enable HTTPS.

Image description

2.3 Testing Protection

  • Simulate SQL Injection: http://<IP or domain>:<port>/?id=1%20AND%201=1

Image description

  • Simulate XSS: http://<IP or domain>:<port>/?html=<script>alert(1)</script>

Image description

2.4 Configuring Protection

You can configure protection settings like:

  • Rate Limiting
    Image description

  • Custom Rule
    Image description

  • Detection Mod
    Image description

  • Settings
    Image description

Top comments (0)