As a result of horrible, horrible errors, we've changed how we connect Apache to Tomcat. We were using mod_jk:
JkMount /path ajp13
Now we're using mod_proxy_ajp:
ProxyPass /path ajp://localhost:8009/path
ProxyPassReverse /path ajp://localhost:8009/path
However, there's a feature that JkMount offered but ProxyPass doesn't: the ability to select on file types. This made it possible to proxy html files, but not images - in other words, to let the nice fast Apache serve the static stuff, and resorting to the slow Tomcat only for the dynamic stuff.
JkMount /*.html ajp13
Is there any way of achieving this with ProxyPass? Possibly using a surrounding <Location> directive or something like that?
Use ProxyPassMatch:
ProxyPassMatch ^/(path/.*\.html)$ ajp://localhost:8009/$1
Edited: Marcus Downing’s correction
Not your issue but something to watch out for using this configuration. While using apache mod_proxy to connect to tomcat my error log was showing dropped connections under moderate load. Adding this to httpd.conf solved my problems.
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With