I am trying to create a Reverse Proxy that match every URL except one in Apache 2.2. It works on Apache 2.4 (Centos 7), but not in Apache 2.2 (Centos 6.6) ...
# Do not modify this
<LocationMatch "^/my-website-2">
ProxyPass http://X.X.X.X:PORT/my-website-2
ProxyPassReverse http://X.X.X.X:PORT/my-website-2
(...)
</LocationMatch>
# Match every URL except the one finishing with /redirect
<LocationMatch "^/my-website(?!/redirect)">
ProxyPass http://X.X.X.X:PORT/my-website
ProxyPassReverse http://X.X.X.X:PORT/my-website
AuthType XXX
RequestHeader set XXX YYY
(...)
</LocationMatch>
# Do anothers directives with this URL only, finishing with /redirect
<Location "/my-website/redirect">
AuthType XXX
(...)
</Location>
My server is looking for /var/www/html/my-website (that doesn't exist) when I type https://my-server.com/my-website because the regex doesn't match ^/my-website(?!/redirect)
I know that Apache 2.2 doesn't understand every negative PCRE regex but it seems that some tricks exist... See :
- Apache location directive - PCRE negative combinations (match all but..)
- https://stackoverflow.com/questions/3404037/how-to-make-a-regex-for-files-ending-in-php
- https://stackoverflow.com/questions/8545680/how-to-tell-apache-to-locationmatch-opposite-of-this
Then, I try a simple regex :
<LocationMatch "/my-website(.*)">
... and it appears that is not even interpreted as PCRE ... With this use case, if I type /my-website(.*) in the URL, it works.
Same behaviour with (From http://httpd.apache.org/docs/2.2/en//mod/core.html#locationmatch) :
<LocationMatch "/(extra|special)/data">
... I need to type http://my-server.com/(extra|special)/data in the URL bar of the browser.
Does Apache HTTPd 2.2 need an additionnal package to understand PCRE in LocationMatch ?
Installed packages :
httpd.x86_64 2.2.15-60.el6.centos.6
apr.x86_64 1.3.9-5.el6_9.1 @Default_Organization_CentOS_6_CentOS_6_Update_x86_64
apr-util.x86_64 1.3.9-3.el6_0.1 @in-std
pcre.x86_64 7.8-7.el6 @Default_Organization_CentOS_6_CentOS_6_Base_x86_64
pcre-devel.x86_64 7.8-7.el6 @Default_Organization_CentOS_6_CentOS_6_Base_x86_64
Weird ...
Thanks