I put up a vps with nginx and the logs show dodgy requests within minutes, how do you guys deal with these?

Edit: Thanks for the tips everyone!

  • Teapot@programming.dev
    link
    fedilink
    English
    arrow-up
    24
    ·
    1 year ago

    Anything exposed to the internet will get probed by malicious traffic looking for vulnerabilities. Best thing you can do is to lock down your server.

    Here’s what I usually do:

    • Install and configure fail2ban
    • Configure SSH to only allow SSH keys
    • Configure a firewall to only allow access to public services, if a service only needs to be accessible by you then whitelist your own IP. Alternatively install a VPN
      • ItsGhost@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        9
        ·
        1 year ago

        Seconded, not only is CrowdSec a hell of a lot more resource efficient (Go vs Python IIRC), having it download a list of known bad actors for you in advance really slows down what it needs to process in the first place. I’ve had servers DDoSed just by fail2ban trying to process the requests.

        • Alfi@lemmy.alfi.casa
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          1 year ago

          Hi,

          Reading the thread I decided to give it a go, I went ahead and configured crowdsec. I have a few questions, if I may, here’s the setup:

          • I have set up the basic collections/parsers (mainly nginx/linux/sshd/base-http-scenarios/http-cve)
          • I only have two services open on the firewall, https and ssh (no root login, ssh key only)
          • I have set up the firewall bouncer.

          If I understand correctly, any attack detected will result in the ip being banned via iptables rule (for a configured duration, by default 4 hours).

          • Is there any added value to run the nginx bouncer on top of that, or any other?
          • cscli hub update/upgrade will fetch new definitions for collections if I undestand correctly. Is there any need to run this regularly, scheduled with let’s say a cron job, or does crowdsec do that automatically in the background?