TOML configuration question regarding fail2ban

So, I'm trying to implement the fail2ban plugin in my setup, and I keep having difficulties with translating the YAML example to a TOML equivalent. I just don't know how to properly format TOML in order to get the regexp rules in place.

The YAML example given is as follows

rules:
urlregexps:
- regexp: "/whoami"
mode: allow
- regexp: "/do-not-access"
mode: block
bantime: "3h"
findtime: "10m"
maxretry: 4
enabled: true

The TOML example doesn't contain the urlregexps however:

[http.middlewares.my-fail2ban.plugin.fail2ban.rules]
bantime = "3h"
enabled = "true"
findtime = "10m"
maxretry = "4"

How can I fit the regexps into this TOML format? Maybe I'm missing some good examples somewhere in the Traefik documentation, or I might be stupid to use TOML in the first place :slight_smile:

Why not use yaml? Have you tried an "AI" to translate the yaml to toml?

I think YAML is finnicky and I have my current config written in TOML, so I am hestiant to commit to a complete switcharoo.

The AI translation option is a nice one, however. Let's see what chatGPT thinks of this. Thanks for the tip!

So, I conviced GPT-4 that is was an YAML and TOML expert and it came with the following solution:

Sure. This is how you would write it in TOML:

[rules]
  [[rules.urlregexps]]
    regexp = "/whoami"
    mode = "allow"
  [[rules.urlregexps]]
    regexp = "/do-not-access"
    mode = "block"
 
bantime = "3h"
findtime = "10m"
maxretry = 4
enabled = true

In TOML, brackets [...] denote sections (like keys in YAML), double brackets [[...]] denote arrays of tables (like lists of dictionaries in YAML), and regular key = value lines correspond to key-value pairs. Booleans (true/false) and numbers (like maxretry = 4) are written the same way in both formats.

I hope that's clear! Please let me know if you need more help with configuration files.

Thanks for the tip @bluepuma77 :slight_smile:

Yeah, I prefer yaml :wink: