DEV Community

Arina Cholee
Arina Cholee

Posted on

Why I switched to an unknown WAF

As a developer who’s been working on both web applications and security solutions, I’m always looking for ways to take control of my infrastructure. This was especially true when I realized the limitations of using a cloud-based WAF like Cloudflare. After migrating to SafeLine WAF, a self-hosted solution, I found more control, better privacy, and greater flexibility. Here's why I made the switch and why I recommend you do the same.

The Problem with Cloudflare: Limited Control and Privacy

For a long time, I relied on Cloudflare to secure my web applications. It worked well in many cases, especially for DDoS protection and general traffic filtering. However, as my applications grew, I began to notice a few limitations:

1. Data Privacy Concerns

Cloudflare, like other cloud-based WAFs, routes your traffic through their infrastructure. This introduces a risk, especially for applications that deal with sensitive data. For projects like QuantBrasil, where user data is critical, this was a dealbreaker. Self-hosting offers far greater privacy because I no longer depend on a third-party service to handle sensitive traffic.

2. Limited Customization

While Cloudflare offers a range of templates and predefined security rules, they weren’t flexible enough for my needs. For example, if I wanted to apply specific security rules to certain endpoints or adjust rate limits based on real-time data, I found Cloudflare lacking in the level of granularity I wanted.

3. External Dependency

Cloudflare’s proxy adds latency and creates a potential single point of failure. During an outage, it’s easy to lose access to your website or application. With SafeLine, I eliminated this risk by hosting everything on my own infrastructure, giving me more control over the security and uptime of my services.

Why SafeLine WAF Was the Right Choice

After evaluating multiple solutions, I found that SafeLine WAF ticked all the boxes for what I was looking for:

1. Full Control Over Traffic and Policies

By self-hosting SafeLine, I gained complete control over traffic. I didn’t have to rely on Cloudflare’s infrastructure. This gave me the flexibility to define custom security rules, configure bot protection, and rate-limiting as per the needs of my applications.

2. Granular Bot Protection

One of the most valuable features of SafeLine is the ability to create fine-tuned bot protection. With SafeLine, I can apply specific rules to different endpoints, block IPs, and even set up JavaScript challenges or CAPTCHAs for sensitive areas like login pages. This level of control is something I couldn’t achieve with Cloudflare’s default settings.

Here’s an example of how I configured rate-limiting for the /api/login endpoint:

# Limit /api/login to 5 requests per second per IP
docker exec -it safeline-cli set-rule /api/login rate-limit 5
Enter fullscreen mode Exit fullscreen mode

3. Better Privacy and Data Control

By self-hosting SafeLine, I don’t need to worry about routing my traffic through third-party servers. My data stays within my infrastructure, providing better privacy for my users, especially for sensitive financial data handled by QuantBrasil.

4. Customizable Rules and Full Visibility

With SafeLine, I can write my own custom rules, including complex firewall configurations. I also have full access to logs and analytics, so I can monitor traffic in real-time, detect potential threats, and adjust security policies as needed.

My Migration Journey from Cloudflare to SafeLine WAF

Migrating from a cloud-based WAF like Cloudflare to a self-hosted solution was a learning experience, but SafeLine made the process much smoother than expected. Here’s a step-by-step look at how I made the transition:

Step 1: Set Up the SafeLine Environment

I set up a Linux server to host SafeLine. The process is straightforward, and I opted for Docker to manage the deployment. Here’s the command to pull and run SafeLine’s Docker container:

docker pull safeline/waf:latest
docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Once the container was running, I could access the SafeLine dashboard to configure my rules.

Step 2: Configure SSL/TLS

Since Cloudflare handled SSL termination for me, I needed to set up SSL on my SafeLine server. I chose to use Let’s Encrypt for automated SSL certificate management.

Step 3: Recreate My Security Rules

I took the time to manually migrate the security rules I had in Cloudflare, such as IP blocklists, rate-limits, and bot protection. SafeLine allows you to create custom rules with regex-based matching, giving you full flexibility.

Step 4: Update DNS and Test

The next step was pointing my DNS records to the new SafeLine server. To minimize risk, I temporarily disabled Cloudflare’s proxy (grey cloud) and monitored the traffic. Everything worked as expected, so I fully switched over to SafeLine.

Step 5: Monitor and Fine-Tune

Once SafeLine was live, I started monitoring the logs for any potential issues. I fine-tuned the rules as needed based on real traffic patterns. SafeLine’s detailed logs made this process much easier and more transparent.

Key Benefits of SafeLine WAF

  • Self-hosted: You control everything from your server to your security policies.
  • Granular Security: Tailor rules for every endpoint, fine-tune bot protection, and rate-limiting.
  • Better Privacy: Keep your data within your own infrastructure, with no third-party interference.
  • Complete Visibility: Access detailed logs and analytics to monitor and adjust your security measures.

Conclusion: Should You Migrate to SafeLine WAF?

If you're looking for more control, privacy, and flexibility in your web security, then switching to a self-hosted WAF like SafeLine is a decision you won’t regret. The migration process may seem a bit involved at first, but the payoff in terms of customizability and security is well worth it.

I highly recommend SafeLine WAF for anyone who wants to take their security infrastructure to the next level. By migrating, you can eliminate the limitations of cloud-based WAFs and gain full ownership of your security policies.

Resources:

Top comments (0)