apache2.conf 和 ProxyPass 中 keepalive 的区别

nwt*_*qrd 4 proxy keepalive 502-error apache2

我在用 Apache 2.2.22

中的 Keepalive 指令之间有什么区别(如果有) /etc/apache2/apache2.conf

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
Run Code Online (Sandbox Code Playgroud)

以及/sites-enabled使用 ProxyPass 时配置中的指令

 ProxyPass / http://localhost:8080/app/ connectiontimeout=28800 timeout=28800 Keepalive=On
Run Code Online (Sandbox Code Playgroud)

小智 5

主配置中的 KeepAlive

Apache 通常使用 HTTP 1.0 协议进行通信,在响应后关闭连接。此处的KeepAlive On参数将使 apache 使用 HTTP 1.1,其中单个 TCP 连接用于发送多个请求/响应。当大量请求来自单个客户端时,这会使服务器更快。

ProxyPass 中的 KeepAlive

在这里,Apache 将发送一个 KeepAlive 探测到上游服务器(请求被代理到)以保持连接处于活动状态。当 Apache 和上游服务器之间有防火墙会断开不活动的连接时,这很有用。

参考

主要配置: https : //httpd.apache.org/docs/2.4/mod/core.html

ProxyPass: https : //httpd.apache.org/docs/2.2/mod/mod_proxy.html