Recently, I was tasked with a challenge: Build an automated defense system for a live Nextcloud instance. The goal wasn't just to block "bad guys," but to build a system that actually learns what a normal day looks like and reacts when things get weird.
Here is the breakdown of how I engineered this system, the statistical math behind it, and why "Sliding Windows" are a developer's best defense.
The Architecture: Under the Hood
This isn't just a script running in a vacuum. To make this work in a production-style environment, I deployed a stack that mirrors real-world DevOps architecture:
The Source: A Nextcloud instance running in Docker.
The Proxy: Nginx, configured to write JSON access logs to a specific path.
The Bridge: A named Docker volume, HNG-nginx-logs, shared between Nginx (writer) and my Python Daemon (reader).
The Brain: A multi-module Python engine that tails these logs in real-time.
Enter fullscreen mode
Exit fullscreen mode
1.…