通过PHP了解Apache上的"408请求超时" [英] Understanding “408 Request Timeout” on Apache with PHP

查看:527
本文介绍了通过PHP了解Apache上的"408请求超时"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题描述-Apache日志

我在Apache日志文件中发现了与此项目相似的项目:

I found items similar to this one in the Apache log file:

166.147.68.243 [24/Feb/2013:06:06:25 -0500] 19 web-site.com "-" 408 - "-"

我有自定义日志格式,而408代表状态.日志格式为:

I’ve got custom log format and 408 here stands for status. The log format is:

LogFormat "%h %t %D %V \"%r\" %>s %b \"%{User-agent}i\"" detailed

通常,日志文件中的行看起来像

And normally the line in the log file looks like

184.73.232.108 [26/Feb/2013:08:38:16 -0500] 30677 www.site.com "GET /api/search... HTTP/1.1" 200 205 "Zend_Http_Client"

这就是为什么408错误行对我来说很奇怪的原因.没有请求被记录,我不知道应该优化什么.

This is why 408 error lines look strange to me. No request is logged and I have no idea on what should be optimized.

问题

如何解决该问题? 我应该收集哪些其他信息或日志? 是什么原因引起的?服务器上有问题吗?还是这绝对是网络连接问题?

How to tackle the issue? What additional information or logs should I gather? What might cause the issue? Is this something wrong on the server? Or is this absolutely a network connectivity problem?

我正在解决此问题,因为我们的客户抱怨他的手机出现408错误.我在日志文件中找到了很多记录,但是我不得不承认我不知道该怎么办.

I’m addressing this because our customer complained that he has got 408 error on his mobile phone. I found many records in the log file but I have to admit I don’t know what to do with this.

我自己的研究

这里已经有关于此主题的几个问题.但是人们更加具体.就像他们讨论某些特定客户端软件和脚本的问题一样.在iPhone上打开某些页面时,这里出现了错误.

There are several questions on this subject already here. But people are much more specific. Like they discus issues with some specific client software and scripts. Here I just got the error when opening some page on iPhone.

例如在 HTTP,408请求超时中,建议执行GET请求开机自检之前.如果我有自定义客户端,可以执行此操作.但是我无法控制用户浏览器的行为.

For example in HTTP, 408 Request timeout, it is suggested to do the GET request before POST. If I have custom client I can do this. But I can not control the behavior of the user’s browser.

猜测#1

当搜索Internet并思考问题时,我发现 https://serverfault.com/questions/383290/too-many-408-error-codes-in-access-log

When searching the Internet and thinking about the issue I found https://serverfault.com/questions/383290/too-many-408-error-codes-in-access-log

建议是更新 Timeout 配置参数恢复为默认值.

The suggestion is to update the Timeout config parameter back to its default value.

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

我首先尝试将值设置为30,因为我认为30秒就足够了. 但是即使使用默认值300秒,我仍然会在日志中获取错误.我在编写此文本时做了tail -f,几分钟后又得到了10行以上.

I tried the value 30 first because I thought 30 seconds should be enough. But even with 300 seconds default value, I continue to get the errors in the log. I did tail -f when I was writing this text and got more then 10 lines in a few minutes.

在我看来,这并不是一个完整的解决方案.

To me this does not look a complete solution.

推荐答案

在对该主题进行了一些研究之后,我得出了以下答案.它是由我们的主要开发人员提供的,我认为它可以很好地说明该主题.

After some studies on the subject I came to the following answer. It is provided by our lead developer and I think it gives good explanation of the subject.

这些错误是完全正常的.它们并不是更大问题的迹象,但是使Apache保持打开状态的正常连接时间超过了允许的时间.

These errors are perfectly normal. They aren't a sign of a larger issue, but normal connections that are holding Apache open for longer than allowed.

例如,客户查询一遍又一遍地运行它们,使Apache保持打开状态. Apache做出了相应的反应,将其适当地关闭了.

For example, client's queries running them over and over kept Apache open. Apache responded by shutting him down appropriately.

如果没有,那么少数人可以接管我们的服务器,并且不允许其他任何人连接.

If it hadn't, than a handful of people could take over our server and not allow anyone else to connect.

这些错误通常来自寻找漏洞的系统,您可以通过打开telnet会话并将其保持打开状态来重新创建它.

Most often these errors are coming from systems looking for exploits, and you can recreate it by opening a telnet session and leaving it open.

同时,在访问日志的末尾添加-f,并在X时间(KeepAliveTimeout)内看到带有相同错误代码的IP弹出窗口.

At the same time, tail -f the access log, and within X time (KeepAliveTimeout) you'll see your IP popup with the same error codes.

在Apache 1.3的早期,这个错误很常见,但是后来出现了2.2,并将其删除,直到我们中的很多人都要求将其返回之前,因为它使我们了解到有多少人只是在打开门而已.端口,而不要求实际资源等.

Back in the days of Apache 1.3, this error was common, but then 2.2 came out and they had it removed until enough of us asked for it to be returned since it give us ideas on how many people are holding open just the port, and not requesting an actual resource, etc.

我认为除了确保将Timeout设置为我在原始问题中所描述的合理值之外,此处无需执行其他任何操作.

I think nothing else should be done here except to make sure to set Timeout to some reasonable value as I have described in original question.

这篇关于通过PHP了解Apache上的"408请求超时"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆