DEV Community

Carrie
Carrie

Posted on

Running a Self-Hosted WAF in the Real World: Notes from Using SafeLine

The problem that pushed me to look at a WAF

Like many small teams, we didn’t start with a security team.

At first, the site was simple: a couple of APIs, a frontend, some admin endpoints hidden behind “security by obscurity”.

Then traffic grew.

Not the good kind.

  • Credential stuffing on /login
  • Aggressive bots scraping pages that didn’t even matter
  • Random scanners hitting /wp-admin, /phpmyadmin, and endpoints we never had
  • Occasional bursts of traffic that weren’t large enough to be a DDoS, but enough to hurt stability

Nothing catastrophic, but enough to waste time and attention.

Rate limiting at the app level helped a bit, but it was reactive and incomplete.

That’s when I started seriously looking at a WAF.


Cloud WAF vs self-hosted: the trade-off I actually cared about

The obvious answer is a cloud WAF. They’re easy, mature, and battle-tested.

I did consider them.

But there were a few reasons I hesitated:

  • Visibility: I wanted to see raw requests, not just dashboards and sampled logs.
  • Control at the application layer: I didn’t want everything abstracted away.
  • Cost predictability: Traffic spikes shouldn’t automatically become billing spikes.
  • Architecture fit: Some services weren’t easily routed through a third-party proxy.

That led me to explore self-hosted WAFs instead.

More responsibility, yes—but also more control.

SafeLine was one of the options I ended up testing in depth.


How SafeLine fits into the traffic path

SafeLine is a self-hosted WAF, typically deployed as a reverse proxy in front of your application.

A common setup looks like this:

Client

SafeLine (WAF)

Upstream (Nginx / App / Load Balancer)

It inspects requests at the HTTP application layer, not just IP or TCP level.

This is important, because most of the real problems today are not volumetric attacks, but abusive behavior that looks almost legitimate.

From an operational point of view, I appreciated that:

  • It runs in your own environment
  • Logs stay local
  • You can correlate WAF behavior directly with upstream logs

SafeLine is self-hosted but not fully open source.

Some components are open (for example, parts of its semantic analysis engine), but it’s not an “everything on GitHub” project—and that’s fine as long as expectations are clear.


Features that actually mattered in practice

I’m intentionally skipping the “long feature list” here.

Instead, these are the parts that made a real difference for me.

1. Anti-bot challenges at the application layer

One thing I underestimated before using a WAF seriously:

how much bot traffic isn’t obviously malicious.

SafeLine’s anti-bot challenge mechanism works at the application layer, not just on IP reputation.

This helped with:

  • Headless browsers scraping content
  • Basic automation that rotated IPs but failed behavioral checks
  • Reducing noise without blanket IP blocking

The key benefit wasn’t “blocking everything”, but reducing junk traffic while keeping false positives manageable.


2. Rate limiting that’s not buried inside the app

Yes, you can implement rate limiting in your code.

But having it outside the app:

  • Keeps logic consistent across services
  • Avoids redeploys just to tweak limits
  • Makes abuse patterns more visible

I found SafeLine’s rate limiting useful especially for:

  • Login endpoints
  • Public APIs
  • Admin or internal paths that shouldn’t be hit often


3. Visibility and debuggability

This is where self-hosted solutions really shine.

When something is blocked, I can:

  • See the exact request
  • Check upstream logs
  • Correlate timestamps
  • Decide whether it’s a false positive or actual abuse

This matters more than people think.

A “secure” system that’s opaque is hard to trust.


A realistic deployment experience (not a full tutorial)

Deployment wasn’t exotic:

  • Docker-based setup
  • Fronted by DNS pointing traffic to SafeLine
  • Upstream services unchanged

What did take time wasn’t installation, but tuning:

  • Deciding which rules to enforce strictly
  • Allow-listing known services (e.g. search engine verification)
  • Avoiding over-blocking during the first few days

This is normal for any WAF.

If someone tells you “zero tuning required”, be skeptical.


Limitations and cases where it’s not a good fit

SafeLine is not for everyone.

I wouldn’t recommend it if:

  • You want zero operational responsibility
  • You expect DNS-level features (like native DNS challenges)
  • You prefer a fully managed, hands-off security model
  • You don’t want to think about false positives at all

Cloud WAFs still make more sense in many scenarios, especially for very large or very distributed systems.

Self-hosting trades convenience for control.


Who SafeLine makes sense for (and who it doesn’t)

Good fit if you are:

  • An independent developer running your own infrastructure
  • A small team without a dedicated security department
  • A DevOps/SRE who wants visibility and control
  • Someone who prefers predictable costs over usage-based surprises

Probably not a good fit if you:

  • Want everything abstracted away
  • Don’t want to manage another component
  • Need globally distributed edge protection out of the box

Final thoughts

SafeLine didn’t magically “solve security”.

What it did was give me leverage:

  • Better signal-to-noise ratio
  • More control at the HTTP layer
  • Fewer surprises when something goes wrong

For teams comfortable owning their infrastructure, that trade-off can be worth it.

Top comments (0)