Search code examples
apacheproxymod-jkajpproxypass

Using ProxyPass for pages but not images


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?


Solution

  • Use ProxyPassMatch:

    ProxyPassMatch ^/(path/.*\.html)$ ajp://localhost:8009/$1
    

    Edited: Marcus Downing’s correction