在命名虚拟主机中使用多个ServerPath指令
问题描述:
我试图创建一个虚拟主机dev.company.com,它根据域后的路由到达不同的应用程序。具体而言,我想:在命名虚拟主机中使用多个ServerPath指令
- /詹金斯 - 路由到詹金斯服务器
- /应用 - 路由到一个登陆页面链接到各种应用
- /三叶草 - 路由到特定詹金斯建设报告 - http://dev.company.com/jenkins/job/proj-master-clover/clover/
- /- 一切应路线到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>
http://dev.company.com/jenkins工作正常,但/ apps和/ clover总是重定向到Tomcat服务器。正确的方法来做到这一点?
答
所以使用ServerPath主要是为传统浏览器。这一招,然而,得到一个别名和重定向的虚拟主机的工作,你正在使用的包罗万象:
ProxyPass/<url>
是告诉的ProxyPass忽略某些路径:ProxyPass /path !
符号
所以我最后虚拟主机是这样的:
<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>
和网址是:
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