Difference between keepalive in apache2.conf and in ProxyPass

502-errorApache2keepalivePROXY

I am using Apache 2.2.22

What is the difference, if there is any, between the Keepalive directive in /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

and the directive in the /sites-enabled config when using ProxyPass

 ProxyPass / http://localhost:8080/app/ connectiontimeout=28800 timeout=28800 Keepalive=On

Best Answer

KeepAlive in main conf

Apache usually uses the HTTP 1.0 protocol to communicate, where it closes the connection after the response. The KeepAlive On parameter here will make apache use HTTP 1.1 where single TCP connection is used to send multiple requests/responses. This makes the server more faster when large number of requests are coming from a single client.

KeepAlive in ProxyPass

Here the Apache will send a KeepAlive probe to the upstream server (which the request is proxied to) to keep the connection alive. This is useful when there is a firewall in between the Apache and the upstream server which drops inactive connections.

Reference

Main conf: https://httpd.apache.org/docs/2.4/mod/core.html

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

Related Topic