Search code examples
apachemod-proxy

Can Apache Proxy exclude root (/) while including the rest?


Thanks to this question, I've been able to set-up my development machine. Local files (ico, png, js, css, html, etc) are served directly by Apache.

There's only one glitch. I also want the document root /index.html to be served by Apache and not by the application server.

ProxyPassMatch / ! does that, but then the next line

ProxyPass / http://localhost:8000/ doesn't work (obviously).

My WSGI server doesn't have a special syntax for Apache to distinguish it.

  • /this should be passed to http://localhost:8000/this
  • /that should be passed to http://localhost:8000/that

ProxyPass /$1 http://localhost:8000/$1 doesn't work either.


Solution

  • I found the answer changing ProxyPassMatch / ! to ProxyPassMatch /$ !

    The '$' means the end of the regex, so only the request ending in / will be served by Apache.

    ProxyPass / http://localhost:8000/ will pass the rest of the requests to the WSGI server.