UserR
UserR

Reputation: 451

Apache LocationMatch with regex not working

I'm trying to configure apache server (version 2.4.46) to do a Location match with regex. I've even tried the regex given in the official document.

It works fine without the regex.

<LocationMatch "/extra/data">
       ProxyPass  http://hello-appv1:8081/V1
       ProxyPassReverse http://hello-appv1:8081/V1
       #ProxyPreserveHost On
</LocationMatch>

When ever I add the regex. It gives a 404 not found error. Here is my virtual host configuration

SSLSessionCache   "shmcb:usr/local/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300
SSLCompression off
SSLProtocol     all +TLSv1.2 -SSLv2 -TLSv1 -TLSv1.1

<VirtualHost *:443>

ServerName apache
SSLInsecureRenegotiation on

# certificate
SSLEngine on
SSLCertificateFile "conf/ssl/apache.crt"
SSLCertificateKeyFile "conf/ssl/apache.key"
   
DocumentRoot "logs"
   
# specify error and custom log location
LogLevel trace8
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog "logs/soapservice.proxy.log" combined
ErrorLog "logs/soapservice.proxy.error.log"


<LocationMatch "/(extra|special)/data">
       ProxyPass  http://hello-appv1:8081/V1
       ProxyPassReverse http://hello-appv1:8081/V1
       #ProxyPreserveHost On
</LocationMatch>


</VirtualHost>

Upvotes: 0

Views: 909

Answers (1)

UserR
UserR

Reputation: 451

You have to add :? before the regex

<LocationMatch "/(:?extra|special)/data"> ProxyPass http://hello-appv1:8081/V1 ProxyPassReverse http://hello-appv1:8081/V1 #ProxyPreserveHost On

Upvotes: 0

Related Questions