Apache vhost + proxy clamping revisited

Found a simple solution to the requirement in my last post:

In order to let apache proxy all requests to a backend-server but also serve some static files from a url-alias, this will be sufficient:

    ServerName www.example.com

    ProxyRequests     Off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    ProxyPass         / http://localhost:8080/
    ProxyPassReverse  / http://localhost:8080/

    RewriteEngine On
    RewriteRule ^/static/(.*) /path/to/static/files/$1 [QSA,L]


No need to let apache listen on another localhost-port and act as proxy front- and backendserver the same time. This is much easier…

The revisited and much nicer apache configuration looks like this:

    |-----> /static/*   served by apache itself from /path/to/static/files/
    |-----> /*
        |----> Tomcat  application server

The mistake i made in the first place was not to rewrite requests to /static/* to a local folder which apache could serve but to proxy those requests to another apache backend-server which was configured to serve such static files only.

Lesson learned: apache2-mod-rewrite as swiss-army-knife for the rescue.