How to Use ProxyMatch or ProxyPassMatch with Regex for mapping multiple Context paths How to Use ProxyMatch or ProxyPassMatch with Regex for mapping multiple Context paths apache apache

How to Use ProxyMatch or ProxyPassMatch with Regex for mapping multiple Context paths


If you put ProxyPassMatch iside a LocationMatch section, the first argument to ProxyPassMatch (regex) must be omitted. It will come from LocationMatch. Example from my (working) configuration:

<VirtualHost *:80>ServerName gopal.lvServerAlias gopal.lv www.gopal.lvProxyPreserveHost On<LocationMatch "^/(img|js|css|att|thumb|banner)/(.+)$">#Note: only 1 argument hereProxyPassMatch "http://192.168.1.11/$1/$2"</LocationMatch>#Note we have 2 arguments hereProxyPassMatch "^/(img|js|css|att|thumb|banner)/(.+)$" "http://192.168.1.11/$1/$2"ProxyPass / http://192.168.1.12/</VirtualHost>

Otherwise, you get the error

ERROR: "Invalid ProxyPass|ProxyPassMatch parameter. Parameter must be in the form 'key=value'"

It is documented here: https://httpd.apache.org/docs/trunk/mod/mod_proxy.html#proxypass


Always use separate lines for comments, and quote the string arguments.There where bug regathering this thing in their bugzila, but I believe you are not using an old version.https://bz.apache.org/bugzilla/show_bug.cgi?id=40439

<LocationMatch "^/(ae/en|ar/en|ar/es|at/en|au/en|be/en|br/en)/">Order Allow,DenyAllow from all#should keep varying as per the regex matched in location matchProxyPass "http://www.xyz.com.au:80/au/en/"#should keep varying as per the regex matched in location matchProxyReverse "http://www.xyz.com.au:80/au/en/" </LocationMatch>


ERROR: "Invalid ProxyPass|ProxyPassMatch parameter. Parameter must be in the form 'key=value'"

This may occur if you have e.g. used RewriteUrl-flags at the end of your Proxy-directive.