Apache Alias 和 LocationMatch 结合使用

Apache Alias 和 LocationMatch 结合使用

我正在尝试配置 Apache 以使用此 url 模式为 3 个应用程序提供服务。

为了http://10.1.0.101http://10.1.0.101/App1请求被转发到另一台服务器。对于 App1 的特殊 URL,将调用输出过滤器(有效)。

为了http://10.1.0.101/App2请求被转发到 Tomcat(有效)

为了http://10.1.0.101/App3请求应该转发到 /var/www/html 但它不起作用并且我得到了 404。我如何使用 directvive Alias 按预期工作?

谢谢大家

<VirtualHost *:80>
   ServerName 10.1.0.101
   ProxyRequests Off
   ProxyPreserveHost On

   #Define a filter
ExtFilterDefine outFilter mode=output \
cmd="/var/www/cgi-bin/out-filter.pl /tmp/out-filter.out"

   DocumentRoot /var/wwww/html

   #forward app3 to /var/www/html ->*** It doensn't work *** 
   Alias /app3 /var/www/html

   #Make App1 default app when user use http://10.1.0.101 ->It works
   <LocationMatch "">
      ProxyPassMatch  http://10.1.0.100/App1
      ProxyPassReverse  http://10.1.0.100/App1
   </LocationMatch>

   #Forward to App2. ->It works
   <LocationMatch "^/app2(.*)">
      ProxyPassMatch   http://localhost:8080/app2$1
      ProxyPassReverse http://localhost:8080/app2/$1
   </LocationMatch>

   #Forward to App1 -> It works
   <LocationMatch "^/app1(.*)">
      ProxyPassMatch   http://10.1.0.100/App1$1
      ProxyPassReverse http://10.1.0.100/App1$1
   </LocationMatch>

   #Forward to App1 and call the filter -> It works
   <LocationMatch "^/App1/specialpage(.*)">
      ProxyPassMatch   http://10.1.0.100/App1/specialpage$1
      ProxyPassReverse http://10.1.0.100/App1/specialpage$1

      SetOutputFilter   outFilter
   </LocationMatch>

</VirtualHost>

答案1

把你的Alias指令在 Location(Match) 中也确保 URL 路径持续合并与您的其他部分。

   <LocationMatch "^/app3(.*)">
        Alias "/var/www/html"
   </LocationMatch>

相关内容