Apache ProxyPass - Regex to Exclude Files

Use ProxyPassMatch. ProxyPass expects fully written path elements, it does not accept regexes.

As ProxyPassMatch takes a regex, this means you must also anchor it:

ProxyPassMatch ^/dgg-[^.]+\.xml$ !

I had a situation where I wanted few images to be picked from Apache webserver and few images to be included from the application server (In my case Jboss). So I wanted one regex that had to both exclude and include. Here is what I added to httpd.conf file under VirtualHost tag.

There are some css and js files which are in jsf jars and jenia popup jars which we will not find on webserver. So reach out to app server.The regexp is looking for all *.js and *.css urls but exclude any urls that have /jenia4faces and /faces in it. This is to make sure scripts like this /MYWEBAPP/jenia4faces/popup/popupFrame/js/popupFrame.js and /MYWEBAPP/faces/myFacesExtensionResource/tabbedpane.HtmlTabbedPaneRenderer/11302665/dynamicTabs.js are still pulled from app server . Rest all .js and .css will be served by webserver.

  ProxyPassMatch ^(/MYWEBAPP/(?!jenia4faces).*\.js)$ !
  ProxyPassMatch ^(/MYWEBAPP/(?!faces).*\.css)$ !
  ProxyPassMatch ^(/MYWEBAPP/(?!jenia4faces).*\.js)$ !
  ProxyPassMatch ^(/MYWEBAPP/(?!faces).*\.css)$ !

where /MYWEBAPP is my web apps root context. Also (?!faces) is to tell if the url doesnt not have "faces" in the url path.