![由于存在许多 If-None-Match 值,请求标头字段的大小超出了服务器限制](https://linux22.com/image/841645/%E7%94%B1%E4%BA%8E%E5%AD%98%E5%9C%A8%E8%AE%B8%E5%A4%9A%20If-None-Match%20%E5%80%BC%EF%BC%8C%E8%AF%B7%E6%B1%82%E6%A0%87%E5%A4%B4%E5%AD%97%E6%AE%B5%E7%9A%84%E5%A4%A7%E5%B0%8F%E8%B6%85%E5%87%BA%E4%BA%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%99%90%E5%88%B6.png)
这是一个有趣的案例,客户端收到“400 错误请求”错误,似乎无法查看使用 Apache/2.2.22 托管在 Ubuntu 12.04.3 LTS 上的 drupal 主页:
错误的请求
您的浏览器发送了此服务器无法理解的请求。
请求标头字段的大小超出了服务器限制。
数据包嗅探输出:
...
T 2013/09/02 15:23:10.458167 ###.###.###.###:40027 -> ###.###.###.###:80 [A]
GET / HTTP/1.0.
If-None-Match: "1363160742-0", "1363165573-1", "1363175854-1", "1363175854-0", "1363179616-0", "1363181811-0", "1363239319-1", "1363255903-0", "1363259282-0", "1363263398-1", "1363274564-0", "1363329642-0", "1363332613-1", "1363333851-0", "1363599826-0", "1363678909-0", "1363684227-1", "1363699732-0", "1363755181-0", "1363765691-1", "1363767178-0", "1363780208-0", "1363787589-0", "1363795259-1", "1363852409-1", "1363863225-1", "1363928115-0", "1363951793-0", "1363951793-1", "1364133610-1", "1364187608-1", "1364187608-0", "1364203083-0", "1364208174-0", "1364214930-0", "1364219815-0", "1364274441-1", "1364280930-0", "1364280930-1", "1364286055-1", "1364298840-0", "1364298840-1", "1364360674-0", "1364364356-1", "1364381508-0", "1364385520-1", "1364460734-0", "1364882595-1", "1364903271-0", "1364967946-0", "1364967946-1", "1364981713-0", "1364985142-1", "1364992835-1", "1365061578-0", "1365065290-1", "1365076128-0", "1365141088-1", "1365167701-0", "1365171024-0", "1365402404-1", "1365402404-0", "1365411731-1", "1365416882-0", "1365476715-0", "1365487578-0", "1365488880-1", "1365503922-1", "1365514224-1", "1365579101-0", "1365580320-0", "1365582817-0", "1365584926-0", "1365589524-0", "1365608307-0", "1365649987-0", "1365682295-0", "1365685083-0", "1365770532-1", "1365770532-0", "1365844566-0", "1365996619-1", "1366093719-1", "1366093719-0", "1366115408-0", "1366180275-1", "1366186431-0", "1366196476-0", "13662669
...
在这个阶段,我不能 100% 确定它是否仅限于特定的客户端,但用户使用以下用户代理字符串报告了该错误:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/534.57.7 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.7
现在剩下的问题是该怎么办,是服务器问题还是客户端行为不当?
答案1
您已经找到问题所在。某些用户代理和某些请求对于 Web 服务器默认值来说太大了。这似乎是一个愚蠢的问题,但它一直在发生在我身上nginx
。通常是在出现愚蠢的 cookie 名称和上传时……无论如何……
解决方案就是提高请求限制。你可以全局执行此操作,也可以只针对你的网站执行此操作指令LimitRequestFieldSize
:
LimitRequestFieldSize 32768
限制为 32KB(默认为 8KB)。