Incoherent rant.

I’ve, once again, noticed Amazon and Anthropic absolutely hammering my Lemmy instance to the point of the lemmy-ui container crashing. Multiple IPs all over the US.

So I’ve decided to do some restructuring of how I run things. Ditched Fedora on my VPS in favour of Alpine, just to start with a clean slate. And started looking into different options on how to combat things better.

Behold, Anubis.

“Weighs the soul of incoming HTTP requests to stop AI crawlers”

From how I understand it, it works like a reverse proxy per each service. It took me a while to actually understand how it’s supposed to integrate, but once I figured it out all bot activity instantly stopped. Not a single one got through yet.

My setup is basically just a home server -> tailscale tunnel (not funnel) -> VPS -> caddy reverse proxy, now with anubis integrated.

I’m not really sure why I’m posting this, but I hope at least one other goober trying to find a possible solution to these things finds this post.

Anubis Github, Anubis Website

Edit: Further elaboration for those who care, since I realized that might be important.

  • You don’t have to use caddy/nginx/whatever as your reverse proxy in the first place, it’s just how my setup works.
  • My Anubis sits between my local server and inside Caddy reverse proxy docker compose stack. So when a request is made, Caddy redirects to Anubis from its Caddyfile and Anubis decides whether or not to forward the request to the service or stop it in its tracks.
  • There are some minor issues, like it requiring javascript enabled, which might get a bit annoying for NoScript/Librewolf/whatever users, but considering most crawlbots don’t do js at all, I believe this is a great tradeoff.
  • The most confusing part were the docs and understanding what it’s supposed to do in the first place.
  • There’s an option to apply your own rules via json/yaml, but I haven’t figured out how to do that properly in docker yet. As in, there’s a main configuration file you can override, but there’s apparently also a way to add additional bots to block in separate files in a subdirectory. I’m sure I’ll figure that out eventually.

Edit 2 for those who care: Well crap, turns out lemmy-ui crashing wasn’t due to crawlbots, but something else entirely.
I’ve just spent maybe 14 hours troubleshooting this thing, since after a couple of minutes of running, lemmy-ui container healthcheck would show “unhealthy” and my instance couldn’t be accessed from anywhere (lemmy-ui, photon, jerboa, probably the api as well).
After some digging, I’ve disabled anubis to check if that had anything to do with it, it didn’t. But, I’ve also noticed my host ulimit -n was set to like 1000… (I’ve been on the same install for years and swear an update must have changed it)
After changing ulimit -n (nofile) and shm_size to 2G in docker compose, it hasn’t crashed yet. fingerscrossed
Boss, I’m tired and I want to get off Mr. Bones’ wild ride.
I’m very sorry for not being able to reply to you all, but it’s been hectic.

Cheers and I really hope someone finds this as useful as I did.

  • fireshell@kbin.earth
    link
    fedilink
    arrow-up
    16
    ·
    10 hours ago

    The development of Anubis remains a matter of enthusiasm: Zee is funding the project through Patreon and sponsorship on GitHub, but cannot yet afford to pursue it on a full-time basis. He would also like to hire a key community member, budget permitting.

  • SorteKanin@feddit.dk
    link
    fedilink
    English
    arrow-up
    10
    ·
    10 hours ago

    I’ve, once again, noticed Amazon and Anthropic absolutely hammering my Lemmy instance to the point of the lemmy-ui container crashing.

    I’m just curious, how did you notice this in the first place? What are you monitoring to know and how do you present that information?

  • SorteKanin@feddit.dk
    link
    fedilink
    English
    arrow-up
    2
    ·
    10 hours ago

    Also your avatar and the image posted here (not the thumbnail) seem broken - I wonder if that’s due to Anubis?

    • zoey@lemmy.librebun.comOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      20 minutes ago

      Just updated the post again, yeah. But I think that was due to me changing nameservers for my domain at the time. Cheers.

  • Mora@pawb.social
    link
    fedilink
    English
    arrow-up
    77
    arrow-down
    1
    ·
    edit-2
    20 hours ago

    Besides that point: why tf do they even crawl lemmy. They could just as well create a “read only” instance with an account that subscribes to all communities … and the other instances would send their data. Oh, right, AI has to be as unethical as possible for most companies for some reason.

    • wizardbeard@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      74
      ·
      21 hours ago

      They crawl wikipedia too, and are adding significant extra load on their servers, even though Wikipedia has a regularly updated torrent to download all its content.

    • ZombiFrancis@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      66
      arrow-down
      2
      ·
      21 hours ago

      See your brain went immediately to a solution based on knowing how something works. That’s not in the AI wheelhouse.

    • dan@upvote.au
      link
      fedilink
      English
      arrow-up
      29
      ·
      19 hours ago

      They’re likely not intentionally crawling Lemmy. They’re probably just crawling all sites they can find.

    • AmbitiousProcess@piefed.social
      link
      fedilink
      English
      arrow-up
      22
      ·
      19 hours ago

      Because the easiest solution for them is a simple web scraper. If they don’t give a shit about ethics, then something that just crawls every page it can find is loads easier for them to set up than a custom implementation to get torrent downloads for wikipedia, making lemmy/mastodon/pixelfed instances for the fediverse, using rss feeds and checking if they have full or only partial articles, implementing proper checks to prevent double (or more) downloading of the same content, etc.

    • N0x0n@lemmy.ml
      link
      fedilink
      English
      arrow-up
      6
      ·
      edit-2
      10 hours ago

      Wow, what a combo ! I guess this would reduce the tarpit’s overall power consumption?

      I haven’t looked at your link yet and maybe it already contains my answer, but I wish to customize for how long they are traped into the tarpit before fail2ban kicks in so I can still poison their AI while saving alot of ressources !!

      Edit:

      block anything that visits it more, than X times with fail2ban

      I guess this is it, but I’m not sure how that translates from nepenthese to fail2ban. Need further reading and testing !

      Thanks for the link !

  • blob42@lemmy.ml
    link
    fedilink
    English
    arrow-up
    9
    ·
    edit-2
    17 hours ago

    I am planning to try it out, but for caddy users I came up with a solution that works after being bombarded by AI crawlers for weeks.

    It is a custom caddy CEL expression filter coupled with caddy-ratelimit and caddy-defender.

    Now here’s the fun part, the defender plugin can produce garbage as response so when a matching AI crawler fits it will poison their training dataset.

    Originally I only relied on the rate limiter and noticed that AI bots kept trying whenever the limit was reset. Once I introduced data poisoning they all stopped :)

    git.blob42.xyz {
        @bot <<CEL
            header({'Accept-Language': 'zh-CN'}) || header_regexp('User-Agent', '(?i:(.*bot.*|.*crawler.*|.*meta.*|.*google.*|.*microsoft.*|.*spider.*))')
        CEL
    
    
        abort @bot
        
    
        defender garbage {
    
            ranges aws azurepubliccloud deepseek gcloud githubcopilot openai 47.0.0.0/8
          
        }
    
        rate_limit {
            zone dynamic_botstop {
                match {
                    method GET
                     # to use with defender
                     #header X-RateLimit-Apply true
                     #not header LetMeThrough 1
                }
                key {remote_ip}
                events 1500
                window 30s
                #events 10
                #window 1m
            }
        }
    
        reverse_proxy upstream.server:4242
    
        handle_errors 429 {
            respond "429: Rate limit exceeded."
        }
    
    }
    

    If I am not mistaken the 47.0.0.0/8 ip block is for Alibaba cloud

    • azertyfun@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 hours ago

      If I am not mistaken the 47.0.0.0/8 ip block is for Alibaba cloud

      That’s an ARIN block according to Wikipedia so North America, under Northen Telecom until 2010. It does look like Alibaba operate many networks under that /8, but I very much doubt it’s the whole /8 which would be worth a lot; a /16 is apparently worth around $3-4M, so a /8 can be extrapolated to be worth upwards of a billion dollars! I doubt they put all their eggs into that particular basket. So you’re probably matching a lot of innocent North American IPs with this.

      • blob42@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        3 hours ago

        Right I must have just blanket banned the whole /8 to be sure alibaba cloud is included. Did some time ago so I forgot

    • dan@upvote.au
      link
      fedilink
      English
      arrow-up
      22
      ·
      19 hours ago

      tbh I kinda understand their viewpoint. Not saying I agree with it.

      The Anubis JavaScript program’s calculations are the same kind of calculations done by crypto-currency mining programs. A program which does calculations that a user does not want done is a form of malware.

      • Natanox@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        27
        ·
        edit-2
        19 hours ago

        That’s guilt by association. Their viewpoint is awful.

        I also wished there was no security at the gate of concerts, but I happily accept it if that means actual security (if done reasonably of course). And quite frankly, cute anime girl doing some math is so, so much better than those god damn freaking captchas. Or the service literally dying due to AI DDoS.

        Edit: Forgot to mention, proof of work wasn’t invented by or for crypto currency or blockchain. The concept exists since the 90’s (as an idea for Email Spam prevention), making their argument completely nonsensical.

      • interdimensionalmeme@lemmy.ml
        link
        fedilink
        English
        arrow-up
        7
        ·
        15 hours ago

        Requiring client to runs client side code, if tolerated, will lead to the extinction of pure http clients. That in turn will enable to drm the whole web. I rather see it all burn.

    • chihuamaranian@lemmy.ca
      link
      fedilink
      English
      arrow-up
      16
      ·
      18 hours ago

      The FSF explanation of why they dislike Anubis could just as easily apply to the process of decrypting TLS/HTTPS. You know, something uncontroversial that every computer is expected to do when they want to communicate securely.

      I don’t fundamentally see the difference between “The computer does math to ensure end-to-end privacy” and “The computer does math to mitigate DDoS attempts on the server”. Either way, without such protections the client/server relationship is lacking crucial fundamentals that many interactions depend on.

      • SheeEttin@lemmy.zip
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        4 hours ago

        Right. One of the facets of cryptography is rounds: if you apply the same algorithm 10,000 times instead of just one, it might make it slightly slower each time you need to run it, but it makes it vastly slower for someone trying to brute-force your password.

      • rtxn@lemmy.world
        link
        fedilink
        English
        arrow-up
        9
        ·
        18 hours ago

        I’ve made that exact comparison before. TLS uses encryption; ransomware also uses encryption; by their logic, serving web content through HTTPS with no way to bypass it is a form of malware. The same goes for injecting their donation banner using an iframe.

  • e0qdk@reddthat.com
    link
    fedilink
    English
    arrow-up
    44
    arrow-down
    4
    ·
    1 day ago

    I don’t like Anubis because it requires me to enable JS – making me less secure. reddthat started using go-away recently as an alternative that doesn’t require JS when we were getting hammered by scrapers.

    • BakedCatboy@lemmy.ml
      link
      fedilink
      English
      arrow-up
      45
      ·
      1 day ago

      Fwiw Anubis is adding a nojs meta refresh challenge that if it doesn’t have issues will soon be the new default challenge

      • dan@upvote.au
        link
        fedilink
        English
        arrow-up
        2
        ·
        19 hours ago

        Won’t the bots just switch to using that instead of the heavier JS challenge?

        • Sekoia@lemmy.blahaj.zone
          link
          fedilink
          English
          arrow-up
          13
          ·
          19 hours ago

          They can, but it’s not trivial. The challenge uses a bunch of modern browser features that these scrapers don’t use, regarding metadata and compression and a few other things. Things that are annoying to implement and not worth the effort. Check the recent discussion on lobste.rs if you’re interested in the exact details.

  • NotSteve_@piefed.ca
    link
    fedilink
    English
    arrow-up
    10
    arrow-down
    1
    ·
    edit-2
    19 hours ago

    I love Anubis just because the dev is from my city that’s never talked about (Ottawa)

    • SheeEttin@lemmy.zip
      link
      fedilink
      English
      arrow-up
      5
      ·
      19 hours ago

      Well not never, you’ve got the Senators.

      Which will never not be funny to me since it’s Latin for “old men”.

      • NotSteve_@piefed.ca
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        17 hours ago

        Hahaha I didn’t know that but that is funny. Admittedly I’m not too big into hockey so I’ve got no gauge on how popular (edit: or unpopular 😅) the Sens are

  • dan@upvote.au
    link
    fedilink
    English
    arrow-up
    7
    ·
    19 hours ago

    The Anubis site thinks my phone is a bot :/

    tbh I would have just configured a reasonable rate limit in Nginx and left it at that.

    Won’t the bots just hammer the API instead now?

    • Flipper@feddit.org
      link
      fedilink
      English
      arrow-up
      9
      ·
      17 hours ago

      No. The rate limit doesn’t work as they use huge IP Spaces to crawl. Each IP alone is not bad they just use several thousand of them.

      Using the API would assume some basic changes. We don’t do that here. If they wanted that, they could run their own instance and would even get notified about changes. No crawling required at all.

  • TomAwezome@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    ·
    20 hours ago

    Thanks for the “incoherent rant”, I’m setting some stuff up with Anubis and Caddy so hearing your story was very welcome :)