You probably want to use ProxyPassMatch. You can use it like:
ProxyPassMatch ^(/.*\.cgi)$ ajp://localhost:8009$1
to proxy all requests ending in .CGI. If you wish to proxy multiple extensions just add more lines or edit the regex. Then you just have to make sure your VirtualHost is setup to serve the remaining image types.
For the benefit of others, I'll answer my own question. Actually, Tomcat (since version 6) provides a quite easy solution for adding URI prefixes to webapps, by prefixing the webapp folder or WAR file name with that prefix (or those prefixes), separated by a hash. So, e.g.:
${catalina.base}/webapps/apps#my_app
${catalina.base}/webapps/apps#my_app2.war
...would make both accessible via http://localhost:8082/apps/my_app/ and http://localhost:8080/apps/my_app2/, respectively, without any further configuration in ${catalina.base}/conf/server.xml.
It is explained somewhat cryptically in the Tomcat Context Container reference, but see this kind message on the Tomcat-users mailing list helped me a lot.
Unfortunately, there's a catch: apparently, Cocoon (up to 2.1.11, haven't tested with 2.2 apps) chokes on webapps whose paths contain a hash (see https://issues.apache.org/jira/browse/COCOON-2270).
Yet, there is a workaround for those Cocoon-based webapps, as shown in following configuration steps:
- move the folder or WAR file containing the webapp outside of the host's appBase path, e.g.: F:\cocoonApps\my_CocoonApp
add a file ${catalina.base}\conf\Catalina[host name][prefix]#[app name].xml, e.g.: ${catalina.base}\conf\Catalina\localhost\apps#my_CocoonApp.xml, with following content:
<Context docBase="F:/cocoonApps/my_CocoonApp"/>
Using this workaround, even Cocoon webapps are happy when accessed at e.g. http://localhost:8082/apps/my_CocoonApp/. This could allow for quite flexible managment overhead of Tomcat webapps:
- non-Cocoon-based webapps: just add them in the Host's appBase, prefixing the name of the folder or WAR file with the desired prefix(es), separated with a hash (#). Adding new non-Cocoon webapps requires no further steps than storing them with the desired URI prefix.
- Cocoon-based webapps: store them outside of the Host's appBase, with just the unprefixed webapp name. Additionally, add a context file for each Cocoon-based webapp, specifying the of the webapp as explained above. This additional step then is only needed for Cocoon-based webapps.
With the Apache proxy settings explained in my original question, this makes it possible to flexibly add Tomcat apps and have them reverse proxied behind Apache using the /apps/ URI prefix.
Best Answer
According to the Tomcat Wiki, you must place your war file outside of
webapps
to prevent double deployment. ThedocBase
pointing to the full path of your WAR file, something like this: