Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 330
Marcus Downing Avatar asked Dec 13 '25 19:12

Marcus Downing


2 Answers

Use ProxyPassMatch:

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

Edited: Marcus Downing’s correction

like image 174
kmkaplan Avatar answered Dec 16 '25 21:12

kmkaplan


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
like image 30
jason saldo Avatar answered Dec 16 '25 22:12

jason saldo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!