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

3

5

I am using IBM's IHS Webserver built on top of Apache Web server Version 2.2.4.

My requirement is to proxy pass a various Context path using regular expression in match.

I tried using ProxyPassMatch but I get below error

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

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

Kindly advice how this can be achieved.

Regards Sridhar

Impious answered 24/11, 2015 at 5:4 Comment(1)
This is unsolvable unless you provide exactly what you configured.Recession
N
11

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.lv
ServerAlias gopal.lv www.gopal.lv
ProxyPreserveHost On

<LocationMatch "^/(img|js|css|att|thumb|banner)/(.+)$">
#Note: only 1 argument here
ProxyPassMatch "http://192.168.1.11/$1/$2"
</LocationMatch>

#Note we have 2 arguments here
ProxyPassMatch "^/(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

Necaise answered 6/11, 2016 at 10:7 Comment(0)
Q
2

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,Deny
Allow from all
#should keep varying as per the regex matched in location match
ProxyPass "http://www.xyz.com.au:80/au/en/"
#should keep varying as per the regex matched in location match
ProxyReverse "http://www.xyz.com.au:80/au/en/" 
</LocationMatch>
Quiff answered 29/6, 2017 at 7:45 Comment(1)
add some explanation to your answerMatildematin
R
0

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.

Recession answered 6/7, 2016 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.