0

This was a question in a recent interview I took. I answered, that to my awareness there is no such way. But I am not sure. Is there a way to stop Apache web server from answering an HTTP request? I used PHP as the language of choice, if it makes a difference.

1 Answer 1

0

To better understand this answer you need to understand the networking "OSI 7 Layer Networking Model". (More details here: https://en.wikipedia.org/wiki/OSI_model )

What this demonstrates is that Apache will "handle" a request before PHP code even begins to execute. (Apache operates at layers 5,6, and 7, where PHP Typically Operates on top of apache).

Therefore PHP code is going to be ill equipped to "stop" apache from Answering an HTTP request. Instead, you will want to look at blocking access entirely (A Firewall [Either hardware of software based], operating at layer 3/4) or you will need apache to have logic to not handle the request.

This is actually more of a security question, than a programming question. Typically for this use case you would want an apache module to make a determination inside apache about handling a request. A few good modules for this are: mod_evasive, mod_security

Please let me know if you have any questions, Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.