r/webdev • • 5d ago

Discussion I am getting cooked by bot traffic.

Post image

why this is happening. Is this normal? I’m using Cloudflare and have already blocked several countries. My application is built with Next.js. What should I do to get rid of bot problem. Or it's inevitable.

33 Upvotes

37 comments sorted by

27

u/ReiOokami 5d ago edited 5d ago

Robots.txt, captcha, rate limit, login wall, paywall, cache, cdn, lots of things you can do to help.

Unfortunately nothing you can do to stop it esp in this ai agent data scraping world these days.

6

u/Gremlation 4d ago

What should I do to get rid of bot problem.

What problem? Your stats max out at about 500 views per hour. This is a tiny amount of traffic even a low powered server can handle with ease. What do you mean you're "getting cooked"? What do you think "cooked" means?

1

u/Cow_Master66 4d ago

Cloudflare has settings to assist.

1

u/Pretty_Judgment5481 3d ago

Tried. Doesnt help that much.

4

u/fullbl-_- 5d ago

Search for patterns in logs and set up fail2ban!

2

u/virtualgeek15 5d ago

Umami is awful at blocking bots from reporting, too.

2

u/ramirex 5d ago

unless you’re on some free vps I wouldn’t call 2k visits getting cooked

2

u/boer0327 4d ago

country blocks rarely help since scrapers just run off US and EU cloud IPs. check your cloudflare security events and challenge the top hosting ASNs instead.

2

u/michaelbelgium full-stack 5d ago

Don't use cloudflare. They're specificly getting targetted.

(Source: my websites don't have cloudflare and never get attacked)

2

u/Vegetable-Capital-54 5d ago edited 5d ago

How does "getting cooked" manifest, and what makes you worry about "bot problem"?

Personally, I run many websites, some for 20+ years, and I have never done anything to block bots. So far I have not noticed any negative effects from it. Aside from the very mild annoyance of making the stats graphs look less smooth on smallest sites, they don't really affect me in any way. It costs me nothing, it has no effect on real users, so why should I put in effort trying to block them? To me blocking whole countries just to have slightly cleaner logs seems like a crazy overreaction.

1

u/Hopeful_Gur_4098 4d ago

You never really got attacked, then. Try building a site with a few hundred thousand pages.

1

u/franker 3d ago

I would just worry about the ones that look for ways to compromise your login and website content. Other than that, I agree with that.

1

u/leechdemon 5d ago

Try to find out what URLs are being visited; are they legit ones, or weird url variable ones? (Page.html?var=sjejajdufne)

If they're legit, many hosts have ways to force redirects for bots. If they're fake, figure out how you got hacked. 🫤

1

u/Agent360dk 5d ago

Cloudflare plus country blocks usually doesn't do much against this kind of traffic since most of it comes from residential or cloud IPs anyway. First thing I'd do is look at what they're actually hitting. If it's mostly your Next.js API routes or /_next/image, put a rate limit rule on those paths in Cloudflare and turn on Bot Fight Mode (or a managed challenge for requests with no cookies and weird user agents). Also check you're caching static and ISR pages at the edge, because uncached SSR hits are what actually cost you. A lot of the AI scrapers now run real headless Chrome so robots.txt and UA checks won't stop them, only rate limits and challenges do.

1

u/Aide_Sea 5d ago

Honestly the first question is whether it's actually costing you anything. If it's just ugly numbers in Umami, that's every public site lol. If your bill or server load is climbing, then it's worth chasing..

1

u/mcmron 4d ago

Did you enable the CF option to disable traffics from AI bots?

1

u/keyboard-thing 4d ago

In addition to the other comments, you should be realistic about your goal. You will not be able to achieve 0 bot traffic unless if you make fighting it your full-time job. I would do weekly reviews after addressing the matter and see how it goes.

1

u/ag789 4d ago edited 4d ago

you are not going to believe this, I've ever setup an web honeypot and 99.9% of traffic are bots, there is no "official" domain just an ip address, 99.9% are bot scraping traffic and most of them are trying to steal secrets like trying to retrieve .env etc.

Most of the "dumb" bots try arbitrary urls, so if it happen to match yours like "/api/v1" you are using a common named endpoint then, so always use an uncommon api url if it doesn't need to be public access.
e.g. make that endpoint /ee41f3e05f12d84e34478de972e00756/v1, that endpoint would likely fall quiet on doing so.

if you run a website, if the traffic is in the low thousands per day, it isn't too difficult to guess that 99% of that is bot traffic. They are quite specific, so if you want to filter them, you need to keep a log of those traffic.

1

u/haiyenpa25 3d ago
What’s the best approach to minimize the risk of bot attacks? I’d like to avoid them too.

1

u/Dominio12 3d ago

Send then gzip bomb.

1

u/jensent6615 3d ago

Check whether the origin is reachable directly. If bots can bypass your proxy and hit the server IP, its challenge/WAF rules never see them; restrict origin ingress to the proxy's published IP ranges and preserve a safe admin path.

1

u/[deleted] 4d ago

[removed] — view removed comment

1

u/Pretty_Judgment5481 3d ago

Yh umami is very bad. I dont understand a lot of its metrics.

1

u/[deleted] 4d ago

[removed] — view removed comment

1

u/Pretty_Judgment5481 3d ago

I moved everything to coolify. Was using railway. Got ripped off🥲

3

u/[deleted] 5d ago

[removed] — view removed comment

1

u/webdev-ModTeam 3d ago

We do not allow any commercial promotion or solicitation. This can lead to a permanent ban from the subreddit.

1

u/[deleted] 4d ago

[removed] — view removed comment

1

u/webdev-ModTeam 3d ago

Your post/comment has been determined to be a low-effort post or comment. This includes title-only posts, easily searchable questions, vague/open-ended discussion prompts, LLM generated posts or comments, and posts/comments that do not provide enough context for meaningful replies or discussion.