Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

binggle's avatar

I got DDOS attack.

I have two routes.

in web.php

Route::get('/', function () {
    return view('welcome');
});

Route::resource('posts', PostController::class );

I could find errors in log file.

Attacker send request something like these.

/?121asdasd
/?asd121
/posts/av123
/posts/123vv

It made an error file very big and it consumes too much php process up to max.

I would like to restrict the input and keep their ips in database to ban.

How can I restrict user router input optimally ?

0 likes
15 replies
mabdullahsari's avatar

Why are you logging these?

Does your app crash whenever an invalid URL is requested? If that's the case, you should fix that.

404's should not be logged.

binggle's avatar

@mabdullahsari

Actually it is be done by nginx.

And the problem is that the attack request consumes all limited php processes.

So server can not serve another request.

Big logging file is not the top trouble.

It consumes all php processes not to serve normal request.

mabdullahsari's avatar

@binggle Yeah ok, you should ban those IP's on the server's firewall using what @tykus has suggested. A WAF is not really an option because it will keep spawning PHP processes.

binggle's avatar

@Sinnbeck

Thanks.

Actually cloudflare is what I did for first-aid.

But I am looking for ways with laravel.

Sinnbeck's avatar

@binggle you said the problem is with nginx, so you cannot do anything to mitigate it with laravel. Nginx comes before laravel

binggle's avatar

@Sinnbeck My experiences with nginx is not much.

Customizing ban2fail with nginx was hard and it did not work even though I followed guide somewhere in internet.

So I think I can find same way with laravel.

Thanks.

binggle's avatar

@Sinnbeck I checked all now.

All is about blocking ips . not restrict or check Request Input.

I need to check route inputs and decide it to fail or success first.

I feel and guess I have to make middleware for it.

But also I guess the best place is the router not middleware cause of loading duty.

Thanks.

tykus's avatar
tykus
Best Answer
Level 104

@binggle you can install fail2ban on the server and create rules to automatically ban the incoming requests.

binggle's avatar

@tykus I tried it before. but customizing with nginx is hard and failed.

Thanks.

binggle's avatar

@tykus thanks for informations.

I checked the last course.

it was about to install ban2fail and configuration.

I guess I need more deep and skilled customization guide.

Thanks.

Please or to participate in this conversation.