Hey all, i’ve decided I should probably setup something else to help block nefarious IP addresses. I’ve been looking into CrowdSec and Fail2Ban but i’m not really sure the best one to use.

My setup is OpnSense -> Nginx Proxy Manager -> Servers. I think I need to setup CrowdSec/Fail2Ban on the Nginx Proxy Manager to filter the access logs, then ideally it would setup the blocks on OpnSense - but i’m not sure that can be done?

Any experience in a setup like this? I’ve found a few guides but some of them seem fairly outdated.

Edit: thanks everybody for the great info. General consensus seems to be with crowdsec so I’ll go down that path and see how it goes.

Edit 2: So after having it up and running for the better part of a day, i’m going to remove it again. For some reason there was a performance impact loading websites, probably because it was waiting for a response from the Crowdsec hub? Either way, after stopping it from running everything is back to normal again. So I might revisit how I do it and probably try Fail2Ban now instead. Thanks everybody

  • Tournesol@feddit.fr
    link
    fedilink
    English
    arrow-up
    25
    arrow-down
    1
    ·
    2 days ago

    I actually refrain from using Crowdsec since we found ourselves with a friend banning each other for no known reasons. (I swear I’m a good boy)

    • irmadlad@lemmy.world
      link
      fedilink
      English
      arrow-up
      15
      arrow-down
      1
      ·
      2 days ago

      As you probably know the crowdsec bouncer doesn’t directly parse logs or do checks like F2B filters. It queries the crowdsec LAPI for decisions and applies them. The “allowed” or “whitelisted” IP logic is handled at the Security Engine or LAPI level, not by the bouncer itself.

      You can whitelist an ip in /etc/crowdsec/whitelists.yaml or even whitelist decisions in the whitelist.yaml as such:

      name: private-ips
      description: Whitelist local and private IPs
      whitelist:
        reason: "Allow local and private IPs"
        ip:
          - "127.0.0.1"
          - "192.168.1.0/24"
        cidr:
          - "10.0.0.0/8"
      

      Then issue sudo systemctl reload crowdsec. Kind of the same concept as F2B’s ignoreip option. If you are using Tailscale to administer the server, then it’s easier to whitelist. IIRC, you can use cscli decisions add --type whitelist --ip 192.168.1.100 --duration 1y but it doesn’t add them to the whitelist.yaml. Instead it keeps them in crowdsec’s database managed by LAPI. To undo: cscli decisions delete --ip 192.168.1.100 --type whitelist

      https://docs.crowdsec.net/u/getting_started/post_installation/whitelists/

      • Matty_r@programming.devOP
        link
        fedilink
        English
        arrow-up
        2
        ·
        21 hours ago

        With the bouncer setup, I assume I need to pass in where to look for logs or something for those to be passed into the lapi? I followed this CrowdSec and Nginx Proxy Manager , as far as I can tell everything is connected an running, I have crowdsec running on OpnSense via the plugin - it appears to be healthy as per the CrowdSec Console.

        npm  | [nginx       ] nginx: [error] [lua] crowdsec.lua:62: init(): error loading captcha plugin: no recaptcha site key provided, can't use recaptcha       
        npm  | [nginx       ] nginx: [error] [lua] ban.lua:37: new(): BAN_TEMPLATE_PATH and REDIRECT_LOCATION variable are empty, will return HTTP 403 for ban decisions
        npm  | [nginx       ] nginx: [alert] [lua] crowdsec_openresty.conf:5):11: [Crowdsec] Initialisation done                                                    
        npm  | [supervisor  ] starting service 'app'...                                                                                                             
        npm  | [app         ] [5/5/2025] [11:26:30 PM] [Global   ] › ℹ  info      Using Sqlite: /data/database.sqlite                                               
        npm  | [supervisor  ] all services started.
        
      • Tournesol@feddit.fr
        link
        fedilink
        English
        arrow-up
        5
        arrow-down
        1
        ·
        2 days ago

        I don’t have much to elaborate on ^^’ but yeah, could have been an hyper specific case but that was my experience with it. I assumed my ip was banned on the crowd or something like that and even if my friend unbanned me twice, the ban came back. Don’t know what really happened for sure.

        • just_another_person@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          arrow-down
          2
          ·
          2 days ago

          Ok…but crowdsec bans abusive IPs. Are you saying your actions got you banned for some reason?

          Also, whitelist first. Ban second.

          • Tournesol@feddit.fr
            link
            fedilink
            English
            arrow-up
            3
            ·
            2 days ago

            I truly don’t think I did anything to get banned. The only thing “non-standard” I do, is having a seedbox