1

I am trying to configure Apache to serve 3 application with this url schema.

For http://10.1.0.101 and http://10.1.0.101/App1 requests are forwarded to another server. For a special url for App1 an output filter is called (it works).

For http://10.1.0.101/App2 requests are forwarded to Tomcat (it works)

For http://10.1.0.101/App3 requests should be forwarded to /var/www/html but it doesn't works and I got a 404. How can I use the directvive Alias to works as expected?

Thanks to all

<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>
  • Using "curl -I" command, I noted that /app3 are forwarded wrongly to 10.1.0.100 so LocationMatch take priority to Alias directive. How I can invert the order? – fciri Aug 9 '18 at 9:43
0

Put your Alias directive in a Location(Match) as well to ensure that URL path is merged consistently with your other sections.

   <LocationMatch "^/app3(.*)">
        Alias "/var/www/html"
   </LocationMatch>
  • Thanks @HBruijn♦ but I got and error starting Apache: "Alias not allowed here" – fciri Aug 9 '18 at 10:23
  • Hmmm, that syntax is dependant on he Apache http version "This syntax is available in Apache 2.4.19 and later." – HBruijn Aug 9 '18 at 10:27
  • I will try to update Apache – fciri Aug 9 '18 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.