Apache2 在命名的VirtualHost中使用多个ServerPath指令

Apache2 在命名的VirtualHost中使用多个ServerPath指令,apache2,Apache2,我正在尝试创建一个虚拟主机dev.company.com,它根据域后面的内容路由到不同的应用程序。具体而言,我希望: /jenkins-路由到jenkins服务器 /应用程序-路由到带有各种应用程序链接的登录页 /clover-到特定Jenkins构建报告的路线- /-其他所有内容都应路由到Tomcat服务器 我正在使用以下配置: <VirtualHost *:80> ServerName dev.company.com ServerPath /jenkins Pr

我正在尝试创建一个虚拟主机dev.company.com,它根据域后面的内容路由到不同的应用程序。具体而言,我希望:

  • /jenkins-路由到jenkins服务器
  • /应用程序-路由到带有各种应用程序链接的登录页
  • /clover-到特定Jenkins构建报告的路线-
  • /-其他所有内容都应路由到Tomcat服务器
我正在使用以下配置:

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

ServerName dev.company.com
服务器路径/詹金斯
ProxyPass/jenkinshttp://easyrider:8080/jenkins
ProxyPassReverse/jenkinshttp://easyrider:8080/jenkins
服务器路径/三叶草
重定向/三叶草http://dev.company.com/jenkins/job/proj-master-clover/clover/
服务器路径/应用程序
DocumentRoot“/usr/local/sites/developers”
DirectoryIndex.html
选项索引多视图
服务器路径/
ProxyPass/http://tomcat_server:8080/
ProxyPassReverse/http://tomcat_server:8080/

工作正常,但是/apps和/clover总是重定向到Tomcat服务器。这样做是正确的吗?

因此,使用ServerPath主要是针对传统浏览器。然而,在使用“一网打尽”的VirtualHost中获得别名和重定向的诀窍是:

ProxyPass / <url>
网址如下:

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