Answer the question
In order to leave comments, you need to log in
How to display a blank page in PHP?
There is a config on the server that allows you to determine whether the visitor is part of the attack or not, it works properly. The bottom line is that the bot gives such visitors a 503 error. But in times of huge attacks on the site, the output of 503 errors tens of thousands of times apparently overloads the server.
It occurred to me that if this is not an error output but a blank page, then there will be no such problem.
Part of the code responsible for the 503 error:
if ($isFakeBot) {
http_response_code(503);
exit;
}
Answer the question
In order to leave comments, you need to log in
The problem with such protection against DDOS in PHP is that the attacking user still manages to run the script in PHP, albeit with minimal resources. If your server application architecture is not built on an event loop (as a rule, ordinary sites), then a separate system process is allocated for each running script - not the most economical version of the PHP server.
Therefore, negligent users should be rejected as early as possible.
You can also identify a bad user in PHP, but it is better to entrust the work of cutting him off to the system that stands in front of the PHP server. It can be both Apache and Nginx.
Define the user and add it to the blacklist file by IP, user agent or cookie, which will be processed by the configured Apache or Nginx.
It is better, of course, that it be a separate firewall, even better - on a piece of iron (but this is unlikely in a rented hosting environment).
Logic of course on the brink of fiction.
Those who have seen questions on the pehap forum do not laugh at jokes.
If the server goes down under attack, then, of course, the issuance of other numbers is to blame. If you give the client the numbers 503, then kranty, the entire server is lying. And if you give out 200 - then zashib everything will fly. L - logic.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question