Tag: outdated filters

  • How to Fix Outdated WP fail2ban Filters on DigitalOcean WordPress 1 click app installation after some time.

    Fix Outdated WP fail2ban Filters on DigitalOcean WordPress

    How to Fix Outdated WP fail2ban Filters on DigitalOcean WordPress

    Step-by-step guide for a DigitalOcean one-click WordPress installation on Ubuntu.

    Example warning

    /etc/fail2ban/filter.d/wordpress-extra.conf is obsolete (version 4.3.0.8).

    WP fail2ban’s WordPress plugin and Ubuntu’s server-side Fail2ban filters are separate. Updating the plugin does not necessarily update the copies under /etc/fail2ban/filter.d/.

    1. Why this happens

    The WordPress plugin emits security events, while server-level Fail2ban reads logs, matches them using filter files, and applies bans through configured firewall actions. The plugin ships filter files in its own directory; Fail2ban uses server-side copies.

    After a plugin update, the server-side filters may remain old. WP fail2ban version 5 also changed its filter layout, so an old wordpress-extra.conf may no longer be needed in a standard setup. Do not assume this without checking your jail configuration.

    Official references: WP fail2ban maintenance guide and version 5 upgrade notes.

    2. Step-by-step instructions

    Step 1 — Connect to the Droplet and check Fail2ban

    Run in SSH
    sudo systemctl status fail2ban --no-pager
    sudo fail2ban-client status

    These commands show whether Fail2ban is running and which jails are active.

    Step 2 — Find the plugin’s supplied filter files

    Run in SSH
    sudo find /var/www -path '*/wp-fail2ban/filters.d/*.conf' -print 2>/dev/null

    A common plugin path is /var/www/html/wp-content/plugins/wp-fail2ban/filters.d/. Use the path actually returned by your server.

    Step 3 — Back up the server filter directory

    Run in SSH before editing files
    sudo cp -a /etc/fail2ban/filter.d "/root/fail2ban-filter-backup-$(date +%F-%H%M%S)"

    This preserves the current filters so you can recover them if needed.

    Step 4 — List the installed WordPress filters

    Run in SSH
    sudo ls -l /etc/fail2ban/filter.d/wordpress*.conf

    Step 5 — Check whether the obsolete extra filter is referenced

    Run in SSH
    sudo grep -Rni 'wordpress-extra' /etc/fail2ban

    If there is no output, no file under /etc/fail2ban appears to reference it. If output appears, review the referenced jail before removing or changing the filter.

    Step 6 — Compare the hard and soft filters

    These commands assume the plugin is in the standard directory. If Step 2 returned another path, replace the source path accordingly.

    Compare hard filter
    sudo diff -u \
      /var/www/html/wp-content/plugins/wp-fail2ban/filters.d/wordpress-hard.conf \
      /etc/fail2ban/filter.d/wordpress-hard.conf
    Compare soft filter
    sudo diff -u \
      /var/www/html/wp-content/plugins/wp-fail2ban/filters.d/wordpress-soft.conf \
      /etc/fail2ban/filter.d/wordpress-soft.conf

    No output means the files are identical. Differences mean they are not identical; review the plugin version and release notes before replacing them.

    Step 7 — Update the hard and soft filters (only after comparing)

    Important: Only run this step if the plugin’s filter files are present and appropriate for your installed release. Review any customisations first. Do not blindly copy a filter from an unrelated release.
    Install source filters into Fail2ban
    sudo install -m 644 \
      /var/www/html/wp-content/plugins/wp-fail2ban/filters.d/wordpress-hard.conf \
      /etc/fail2ban/filter.d/wordpress-hard.conf
    
    sudo install -m 644 \
      /var/www/html/wp-content/plugins/wp-fail2ban/filters.d/wordpress-soft.conf \
      /etc/fail2ban/filter.d/wordpress-soft.conf

    Adjust the source path if your plugin directory differs. WP fail2ban releases may change which filter files are required.

    Step 8 — Remove the old extra filter only if it is not needed

    If the grep in Step 5 produced no output, and you confirmed your installed release and jails no longer need the file, back it up separately:

    Back up the old file
    sudo cp -a /etc/fail2ban/filter.d/wordpress-extra.conf /root/wordpress-extra.conf.backup

    Then, only if you confirmed it is unnecessary:

    Remove obsolete file
    sudo rm /etc/fail2ban/filter.d/wordpress-extra.conf

    Step 9 — Test the configuration

    Run before reloading
    sudo fail2ban-client -t

    Do not reload if the test fails. Read the error and fix the missing filter or invalid configuration first.

    Step 10 — Reload and verify

    Run only if the test passed
    sudo fail2ban-client reload
    sudo systemctl status fail2ban --no-pager
    sudo fail2ban-client status

    If your WordPress jail is actually named wordpress, inspect it with:

    Optional — use your actual jail name
    sudo fail2ban-client status wordpress

    3. Common problems

    • “No such file or directory”: Use Step 2 to locate the real plugin path. Do not guess paths.
    • Warning remains: Check the plugin version and its release notes. The Site Health check may itself have a version-detection issue.
    • Configuration test fails: Do not reload. Review the reported jail/filter error and restore the backup if necessary.
    • No bans appear: Confirm a jail is enabled, reading the expected log, matching events, and applying a working firewall action.
    • allowipv6 warning: This is separate from obsolete filters. The default auto setting is often appropriate; don’t disable IPv6 merely to hide the warning.

    4. Final check

    In WordPress, open Tools → Site Health and check whether the obsolete-filter warning has disappeared. If it remains, confirm the installed WP fail2ban version and compare the server filters with the matching release.

    Official documentation: WP fail2ban maintenance.

    Safety reminder: Do not delete filters or alter jails solely to silence a warning. The goal is compatible filter files, a valid configuration, and active jails that protect the server without locking out legitimate users.

    Copy buttons use your browser’s clipboard permission. If copying is blocked, select the command text and copy it manually.