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.
这是我最近采访的一个问题。我回答说,据我所知,没有这种方式。但我不确定。有没有办法阻止Apache Web服务器回复HTTP请求?我使用PHP作为首选语言,如果它有所作为。
1 个解决方案
#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 )
为了更好地理解这个答案,您需要了解网络“OSI 7层网络模型”。 (更多细节请访问: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).
这表明Apache将在PHP代码开始执行之前“处理”一个请求。 (Apache在第5,6和7层运行,其中PHP通常在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.
因此,PHP代码将无法通过回答HTTP请求来“停止”apache。相反,您将需要完全查看阻止访问(防火墙[基于软件的硬件],在第3/4层运行)或者您将需要apache来使逻辑无法处理请求。
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
这实际上是一个安全问题,而不是编程问题。通常,对于此用例,您需要一个apache模块在apache中确定有关处理请求的信息。一些很好的模块是:mod_evasive,mod_security
- Mod_Evasive:
- https://www.digitalocean.com/community/tutorials/how-to-protect-against-dos-and-ddos-with-mod_evasive-for-apache-on-centos-7
- Mod_Security
- https://geekflare.com/apache-web-server-hardening-security/#6-Mod-Security
Please let me know if you have any questions, Thanks!
如果您有任何疑问,请与我们联系,谢谢!
#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 )
为了更好地理解这个答案,您需要了解网络“OSI 7层网络模型”。 (更多细节请访问: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).
这表明Apache将在PHP代码开始执行之前“处理”一个请求。 (Apache在第5,6和7层运行,其中PHP通常在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.
因此,PHP代码将无法通过回答HTTP请求来“停止”apache。相反,您将需要完全查看阻止访问(防火墙[基于软件的硬件],在第3/4层运行)或者您将需要apache来使逻辑无法处理请求。
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
这实际上是一个安全问题,而不是编程问题。通常,对于此用例,您需要一个apache模块在apache中确定有关处理请求的信息。一些很好的模块是:mod_evasive,mod_security
- Mod_Evasive:
- https://www.digitalocean.com/community/tutorials/how-to-protect-against-dos-and-ddos-with-mod_evasive-for-apache-on-centos-7
- Mod_Security
- https://geekflare.com/apache-web-server-hardening-security/#6-Mod-Security
Please let me know if you have any questions, Thanks!
如果您有任何疑问,请与我们联系,谢谢!