0

我正在尝试将 apache 服务器(版本 2.4.46)配置为与正则表达式进行位置匹配。我什至尝试过官方文档中给出的正则表达式。

没有正则表达式它工作正常。

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

每当我添加正则表达式时。它给出了 404 not found 错误。这是我的虚拟主机配置

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>
4

1 回答 1

0

您必须添加:?在正则表达式之前

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

于 2021-05-21T12:36:11.603 回答