I'm trying to create a virtual host, dev.company.com, that routes to different applications depending on what comes after the domain. Specifically, I want:
- /jenkins - to route to a Jenkins server
- /apps - to route to a landing page with links to various applications
- /clover - to route to a particular Jenkins build report - http://dev.company.com/jenkins/job/proj-master-clover/clover/
- / - everything else should route to a Tomcat server
I'm using the following config:
<VirtualHost *:80>
  ServerName dev.company.com
  ServerPath /jenkins
  ProxyPass /jenkins http://easyrider:8080/jenkins
  ProxyPassReverse /jenkins http://easyrider:8080/jenkins
  ServerPath /clover
  Redirect /clover http://dev.company.com/jenkins/job/proj-master-clover/clover/
  ServerPath /apps
  DocumentRoot "/usr/local/sites/developers"
  <Directory "/usr/local/sites/developers">
        DirectoryIndex index.html
        Options Indexes MultiViews
  </Directory>
  ServerPath /
  ProxyPass / http://tomcat_server:8080/
  ProxyPassReverse / http://tomcat_server:8080/
</VirtualHost>
http://dev.company.com/jenkins works fine, but /apps and /clover always redirect to the Tomcat server. Is the right way to do this?
So using ServerPath's is mostly for legacy browsers. The trick, however, to getting an Alias and a Redirect working in a VirtualHost where you're using the catch-all:
ProxyPass / <url>
is tell ProxyPass to ignore certain paths: ProxyPass /path ! notation
So my final VirtualHost looks like this:
<VirtualHost>
    ServerName dev.company.com
    ProxyPass /jenkins http://easyrider:8080/jenkins
    ProxyPassReverse /jenkins http://easyrider:8080/jenkins
    # Tells ProxyPass to ignore these paths as they'll be handled by Alias and Redirect
    ProxyPass /clover !
    ProxyPass /apps !        
    Redirect /clover http://dev.company.com/jenkins/job/proj-master-clover/clover/
    Alias /apps "/usr/local/sites/developers"
    <Directory "/usr/local/sites/developers">
        DirectoryIndex index.html
        Options Indexes MultiViews
    </Directory>
    ProxyPass / http://tomcat_server:8080/
    ProxyPassReverse / http://tomcat_server:8080/
</VirtualHost>
and the urls are:
http://dev.company.com/jenkins* - will proxy to jenkins http://dev.company.com/jenkins
http://dev.company.com/apps - will proxy to http://dev.company.com/apps/
http://dev.company.com/clover - will redirect to http://dev.company.com/jenkins/job/proj-master-clover/clover/
and everything else will go to tomcat at tomcat_server:8080
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论