[Plugin] Fail2Ban urlregexp help needed

I'm trying to set up the fail2ban plugin and it works with my containous/whoami test container without a urlregexp rule.

I want to secure my Wordpress container by setting a urlregexp rule for the login page /wp-login.php. But it seems that no matter which rule I configure, fail2ban does not filter for the login page but takes all requests to the site for its calculations. This leads to access restrictions relatively fast on all Wordpress pages. My attempts so far (docker-compose of my Wordpress container):

     [ ... ]
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.enabled=true"
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.bantime=5m"
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.findtime=1m"
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.maxretry=5"
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.ports=0:8000"

      # with and without \`
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.urlregexp=`.*\/wp-login.php.*`"
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.urlregexp=.*\/wp-login.php.*"
      - "traefik.http.middlewares.my-fail2ban.plugin.fail2ban.rules.urlregexp=.*\/wp\-login\.php.*" # throws compose parsing error

      - "traefik.http.routers.wordpress.middlewares=my-fail2ban@docker"
      [ ... ]

Is my regex not correct? Or am I mistaken what the urlregexp rule should do?

Thanks in advance,

See my answer on github.
(Sorry for the long delay)

1 Like