阿帕奇/ Tomcat的错误 - 错误页面交付 [英] Apache/Tomcat error - wrong pages being delivered
问题描述
此错误已被我发疯。我们有一个服务器上运行的Apache和Tomcat,服务于多个不同的网站。通常情况下,服务器运行正常,但有时会发生错误的时候,人们都提供了错误的页面! - 的是页别人的要求
This error has been driving me nuts. We have a server running Apache and Tomcat, serving multiple different sites. Normally the server runs fine, but sometimes an error happens where people are served the wrong page - the page that somebody else requested!
线索:
- 会被交付的页面是指那些其他用户要求的近期和以其他方式正确地传递。它已经知道被换两个同时请求。据我所知,没有一个被错误提供的网页都超过几分钟以上。
- 它仅影响正在被Tomcat服务的文件。如图像静态文件不受影响。
- 这不会发生所有的时间。当它发生,它发生于每个人。
- 这似乎在需求高峰期的情况发生。然而,需求还不是非常高的 - 这当然是一个什么样的Apache能应付的范围之内以及
- 重启动Tomcat固定它,但只有几分钟。重启动Apache固定它,但只有几分钟。
- 服务器正在运行的Apache 2和Tomcat 6,使用Java VM 6 Gentoo上。连接是用AJP13,和
JkMount
在&LT指令;虚拟主机方式>
块是正确 - 没有什么用,在任何日志文件。
更多信息:
阿帕奇没有任何形式的缓存打开。 httpd.conf中的所有高速缓存相关的条目及相关的进口说,例如:
Apache does not have any form of caching turned on. All the caching-related entries in httpd.conf and related imports say, for example:
<IfDefine CACHE>
LoadModule cache_module modules/mod_cache.so
</IfDefine>
虽然Apache的选项不包括标志:
While the options for Apache don't include that flag:
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -D JK"
Tomcat的同样不具有任何缓存选项打开,我能找到。
Tomcat likewise has no caching options switched on, that I can find.
<一个href=\"http://stackoverflow.com/questions/246540/apachetomcat-error-wrong-pages-being-delivered#246566\">toolkit's建议的是好的,但在这种情况下不适合。是什么使我相信,错误不能成为我自己的code之内的是,它是正在转移不是简单的几个值 - 这是整个请求,包括URL,参数,会话cookie,全事情。人们变得页回说:你登录为约翰,当他们显然不是。
toolkit's suggestion was good, but not appropriate in this case. What leads me to believe that the error can't be within my own code is that it isn't simply a few values that are being transferred - it's the entire request, including the URL, parameters, session cookies, the whole thing. People are getting pages back saying "You are logged in as John", when they clearly aren't.
更新:
,我要添加以下的HTTP标头Tomcat的服务页面禁用所有形式的缓存:
Based on suggestions from several people, I'm going to add the following HTTP headers to Tomcat-served pages to disable all forms of caching:
Cache-Control: no-store
Vary: *
希望这些标题将不只是Apache的,也可由其他任何缓存或代理可能的方式得到尊重。不幸的是我没有刻意重现这个错误的方式,所以我只是将不得不等待,看看它是否再次打开了。
Hopefully these headers will be respected not just by Apache, but also by any other caches or proxies that may be in the way. Unfortunately I have no way of deliberately reproducing this error, so I'm just going to have to wait and see if it turns up again.
我注意到,正在包括下列头 - 他们可以以任何方式与
I notice that the following headers are being included - could they be related in any way?
Connection: Keep-Alive
Keep-Alive: timeout=5, max=66
更新:
显然,这又发生了,而我睡着了,但现在已经不再发生,我清醒地看到它。再次,有没有什么,我可以看到日志的有用的,所以我没有线索什么实际发生或如何prevent它。
Apparently this happened again while I was asleep, but has stopped happening now I'm awake to see it. Again, there's nothing useful in the logs that I can see, so I have no clues to what was actually happening or how to prevent it.
是否有任何额外的信息,我可以把在Apache或Tomcat的日志,以使这更容易诊断?
Is there any extra information I can put in Apache or Tomcat's logs to make this easier to diagnose?
更新:
由于这再次发生了几次,我们已经改变了Apache如何连接到Tomcat,看它是否影响的东西。我们使用的mod_jk
与这样的指令:
Since this has happened again a couple of times, we've changed how Apache connects to Tomcat to see if it affects things. We were using mod_jk
with a directive like this:
JkMount /portal ajp13
我们现在已经转而使用的mod_proxy_ajp
,就像这样:
We've switched now to using mod_proxy_ajp
, like so:
ProxyPass /portal ajp://localhost:8009/portal
我们会看到,如果这有什么差别。这个错误一直未烦人predictable,因此,如果它的工作与否,我们不能肯定地说。
We'll see if it makes any difference. This error was always annoyingly unpredictable, so we can never definitively say if it's worked or not.
更新:
我们刚刚得到了错误短暂上使用留下了一个网站的mod_jk
,同时使用同一服务器上的姊妹网站的mod_proxy_ajp
没有显示错误。这并不能说明什么,但它确实提供证据证明具有结构转换为的mod_proxy_ajp
可能都有帮助。
We just got the error briefly on a site that was left using mod_jk
, while a sister site on the same server using mod_proxy_ajp
didn't show the error. This doesn't prove anything, but it does provide evidence that swithing to mod_proxy_ajp
may have helped.
更新:
我们只使用的mod_proxy_ajp
得到了错误昨晚再次在网站上,那么清楚这并没有解决它 - 的mod_jk
不是问题的根源。我要去尝试关闭持久连接匿名建议:
We just got the error again last night on a site using mod_proxy_ajp
, so clearly that hasn't solved it - mod_jk
wasn't the source of the problem. I'm going to try the anonymous suggestion of turning off persistent connections:
KeepAlive Off
如果还是失败,那么,我将是足够绝望开始调查GlassFish的。
If that fails as well, I'm going to be desperate enough to start investigating GlassFish.
更新:
该死!问题刚回来。我没有看到它在一段时间,所以我开始认为我们会终于来分类的。我讨厌heisenbugs。
Dammit! The problem just came back. I hadn't seen it in a while, so I was starting to think we'd finally sorted it. I hate heisenbugs.
推荐答案
我们交换的Apache从代理与AJP与HTTP代理。到目前为止,它似乎已经解决了这个问题,或至少大大减少了它 - 这个问题尚未见报道几个月,从那时起应用程序的使用增加了
We switched Apache from proxying with AJP to proxying with HTTP. So far it appears to have solved the issue, or at least vastly reduced it - the problem hasn't been reported in months, and the app's use has increased since then.
的变化是在Apache的httpd.conf。已经开始与的mod_jk
:
The change is in Apache's httpd.conf. Having started with mod_jk
:
JkMount /portal ajp13
我们切换到的mod_proxy_ajp
:
ProxyPass /portal ajp://localhost:8009/portal
后来终于直的mod_proxy
:
ProxyPass /portal http://localhost:8080/portal
您需要确保Tomcat的设置为HTTP服务端口8080上请记住,如果你服 /
,你需要包括 /
上的代理两侧或开始哭闹:
You'll need to make sure Tomcat is set up to serve HTTP on port 8080. And remember that if you're serving /
, you need to include /
on both sides of the proxy or it starts crying:
ProxyPass / http://localhost:8080/
这篇关于阿帕奇/ Tomcat的错误 - 错误页面交付的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!