Wednesday, February 4, 2009

Ensure a stable mod_proxy_ajp connection

Apache Tomcat connector mod_proxy_ajp is recommended Tomcat frontend for Tomcat backend server. It provides better flexibility, scalability and security.

When using a firewall between machine running mod_proxy_ajp and backend Tomcat, the firewall may silently drop connections between the two when the connection is idle, causing following error:

(104)Connection reset by peer: ajp_ilink_receive() can't receive header

The symptom on the user side is when opening a page, usually after a long period of inactivity, it gets a 503 Service Temporarily Unavailable Error. A simple page reload will get the page back, since a new connection is initiated.

To avoid this, add a Keepalive parameter to mod_proxy_ajp to use OS TCP/IP KeepAlive function to send keepalive patches through the firewall:

ProxyPass /path_if_any ajp://backend_tomcat_server:8009/path_if_any keepalive=on

No comments: