apache代理到tomcat保持活动混乱

发布于 2024-08-12 09:07:50 字数 667 浏览 6 评论 0原文

我在 tomcat 6 服务器前面有一个 apache 2.2 服务器。在 apache 上使用 mod_proxy_ajp 将请求代理到 tomcat。相当标准的设置。

如果我需要禁用浏览器的保持活动连接,我该怎么做?

我需要禁用保持活动的http请求,因为我怀疑我的一些用户的防火墙可能会丢弃不活动的保持活动连接,这会随机导致问题。

apache 和 tomcat 上都有各种“保持活动”的配置。

httpd.conf 在设置 ProxyPass 的 httpd.conf 中也有“KeepAlive Off”(这似乎对我的情况没有影响)

,您可以有一个参数“keepalive”,但这仅在有情况下才有帮助我的 apache 和 tomcat 之间有代理/防火墙,在我的情况下没有,也不是问题。

Tomcat 本身,http 连接器有“keepAliveTimeout”和“maxKeepAliveRequests”,但这仅适用于 http 连接器。

tomcat ajp 连接器也有一个“keepAliveTimeout”,但这是针对来自 apache 的 ajp 请求,不确定这是否应该/流向从浏览器到 apache 的真实 HTTP 请求。

最重要的是,还有 HTTP1.0 与 HTTP1.1 的区别。

所以它变得令人困惑......有人可以解释一下吗?

I have an apache 2.2 server infront of a tomcat 6 server. using mod_proxy_ajp on apache to proxy requests to tomcat. pretty standard setup.

If I need to disable keep-alive connections for browsers, how do i do this?

I need to do disable keep-alive http requests because i suspect some of my users have firewalls that might be dropping an un-active keep-alive connection which randomly causes problems.

There are various 'keep alive' bits and pieces of configuration on both apache and tomcat.

httpd.conf has "KeepAlive Off" (which does not seem to be making a difference in my case)

also in httpd.conf where you set ProxyPass, you can have a parameter "keepalive" but this is only supposed to help if there are proxies/firewalls between my apache and tomcat, which there isn't in my case and is not the problem.

Tomcat itself, the http connector has "keepAliveTimeout" and "maxKeepAliveRequests" but this is only for http connectors.

The tomcat ajp connector also has a "keepAliveTimeout", but this is for ajp requests coming from apache, not sure if this should/flows on to the real HTTP request from the browser to apache.

To top it all there is also the HTTP1.0 vs HTTP1.1 differentiation.

So it gets confusing.... can someone please explain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情愿 2024-08-19 09:07:50

有(至少)四个“保持活动”。

  1. 客户端浏览器和 Apache 之间的 HTTP 层保持活动状态。
    (在 HTTP/TCP 连接中启用多个客户端请求。要配置“KeepAlive”指令。)

  2. 客户端浏览器和 Apache 之间的 TCP 层保持活动状态。
    (为了避免连接被防火墙关闭,请定期发送空包(Linux中默认大约2小时)。我不知道如何在Apache中配置。)

  3. Apache 和 Tomcat 之间的 AJP 层保持活动。
    (在 AJP/TCP 连接中启用多个 Apache 请求。“ProxyPass”的“max”和“smax”选项可供配置。)

  4. Apache 和 Tomcat 之间的 TCP 层保持活动状态。
    (与 2 相同,但适用于 Apache 和 Tomcat 之间的防火墙。要配置“ProxyPass”指令的“keepalive”选项。)

因此,您的配置(“KeepAlive off”)可能对客户端和 Apache 内的防火墙正常工作。使用“%X”作为“LogFormat”指令来检查 keep-alive(上述类型 1)是否被禁用。

顺便说一句,我认为当“KeepAliveTimeout”不太大时,防火墙关闭连接不会造成严重问题。
如果您没有问题(除了警告消息),我认为您可以按原样离开。

There are (at least) four “keep-alive”s.

  1. HTTP layer keep-alive between client browser and Apache.
    (Enables multiple client requests in a HTTP/TCP connection. “KeepAlive” directive to configure.)

  2. TCP layer keep-alive between client browser and Apache.
    (To avoid connection to be closed by firewalls, send empty packet periodically (around 2 hours by default in Linux). I don't know how to configure in Apache.)

  3. AJP layer keep-alive between Apache and Tomcat.
    (Enables multiple Apache request in a AJP/TCP connection. “max” and “smax” options for “ProxyPass” to configure.)

  4. TCP layer keep-alive between Apache and Tomcat.
    (Same as 2, but for firewall between Apache and Tomcat. “keepalive” option for “ProxyPass” directive to configure.)

So, your configuration (“KeepAlive off”) might work correctly for firewalls within client and Apache. Use “%X” for “LogFormat” directive to check if keep-alive (of type 1 above) was disabled.

By the way, I think connection closure by firewalls doesn't cause serious problem when “KeepAliveTimeout” is not so large.
If you don't have problem (other than warning messages), in my opinion, you might leave as is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文