View · Search · Index

Using Fail2Ban with OpenACS

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.

  1. Log confirmed probes. A top-level www/index.vuh is a good place to handle probing requests because OpenACS calls it when no more specific page or handler matches. Emit the marker only when a request matches a site-defined probe rule. This example logs the client address and request line for matching probes.

    # www/index.vuh
    set probe_url [ns_conn url]
    if {[regexp -nocase {(^|/)(\.env(\.[^/]+)?|\.git|\.ssh|\.aws)(/|$)} $probe_url]
        || $probe_url in {
            /application_default_credentials.json
            /google/service-account.json
            /vertex-ai-credentials.json
            /.config/gcloud/credentials.db
            /var/task/amplify/backend/function/*/src/index.js
        }} {
        ns_log Notice "F2B_NAVISERVER_PROBE ip=[ns_conn peeraddr] [ns_conn request]"
        ns_return 404 text/plain "Not Found"
        ad_script_abort
    }
    ns_returnnotfound
    ad_script_abort
    

    Tcl in compares literal strings, so * in the final list entry is literal.

    Smoke test. Before enabling the jail, set base to your test site and log to its active NaviServer system log. The query tag identifies this run in the log without changing the path matched by ns_conn url.

    base=https://your-test-site.example
    log=/path/to/error.log
    tag="f2b-smoke-$(date +%s)-$$"
    for path in /.env "/ordinary-missing-$tag"; do
        curl -sS -o /dev/null -w "%{http_code} $path\n" "$base$path?test=$tag"
    done
    grep -F 'F2B_NAVISERVER_PROBE ip=' "$log" | grep -F "test=$tag"
    

    Expect two 404 lines and exactly one marker line, for /.env. The ordinary missing URL should have no marker.

  2. Configure the filter and jail. Use the filter and jail examples in the NaviServer guide. Set logpath to the actual system log on your host, and choose the firewall action for your deployment. Protecting NaviServer with Fail2Ban

  3. Test before enabling bans. Run fail2ban-regex against 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 with sudo 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

previous December 2026
Sun Mon Tue Wed Thu Fri Sat
29 30 1 2 3 4 (1) 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2

Popular tags

17 , 5.10 , 5.10.0 , 5.10.1 , 5.9.0 , 5.9.1 , ad_form , ADP , ajax , aolserver , asynchronous , Azure , bgdelivery , bootstrap , bugtracker , CentOS , COMET , compatibility , conference , CSP , CSRF , cvs , debian , docker , docker-compose , emacs , engineering-standards , exec , fedora , FreeBSD
No registered users in community xowiki
in last 30 minutes
Contributors

OpenACS.org