Using Fail2Ban with OpenACS
Created by Gustaf Neumann, last modified by Gustaf Neumann 12:11 PM, Friday
If automated scanners repeatedly probe your OpenACS site for exposed files or known vulnerabilities, Fail2Ban can reduce unwanted traffic and log noise by temporarily blocking repeat sources. On Linux, run Fail2Ban where it can read NaviServer’s system log and enforce bans against the client addresses recorded there.
Log confirmed probes. In your OpenACS request handler or filter, emit the marker below after a request matches a site-defined probe rule. Keep ordinary 404s and normal crawler traffic out of the ban count. The marker needs only the client address. Leave raw URLs and headers out of it.
ns_log Notice "F2B_NAVISERVER_PROBE ip=[ns_conn peeraddr]"Configure the filter and jail. Use the filter and jail examples in the NaviServer guide. Set
logpathto the actual system log on your host, and choose the firewall action for your deployment. Protecting NaviServer with Fail2BanTest before enabling bans. Run
fail2ban-regexagainst your real system log. Check that the filter matches the probe markers and leaves ordinary log entries alone. After enabling the jail, confirm it is active withsudo fail2ban-client status naviserver-probes. Filter testing and jail setup
Reverse proxies and Docker. Trust forwarded client addresses only from known proxies, and enforce bans where the firewall can see the real client IP. With Docker bridge networking, give the host’s Fail2Ban process access to the container’s log and use the guide’s Docker-specific firewall instructions. NaviServer deployment examples