Apache Web服务器,在同一服务器上的不同端口上的多个应用程序

问题描述:

我有两个应用程序在同一端口(8180)上使用不同上下文在Jboss 6上运行。我在机器端口80上运行Apache。我需要根据正在访问的应用程序将请求指向适当的上下文。Apache Web服务器,在同一服务器上的不同端口上的多个应用程序

我有一个dns条目 - testServ14,它指向服务器IP。

更清晰,应用程序应该通过URL类似

http://testServ14/appAcontext/

http://testServ14/appBcontext/

在的httpd的虚拟主机文件是可访问我应该怎么使用虚拟主机或指令了NameVirtualHost?

我怎样才能做到这一点..

试过以下,但如果你想从一个URL重定向到另一个没有工作......

<VirtualHost *:80> 
ServerName http://testServ14/appA 
ProxyRequests Off 
ProxyVia On 
ProxyPass/http://localhost:8180/appA 
ProxyPassReverse/http://localhost:8180/appA 
ErrorLog logs/error_log 
CustomLog logs/access_log common 
</VirtualHost> 


<VirtualHost *:80> 
ServerName http://testServ14/appB 
ProxyRequests Off 
ProxyVia On 
ProxyPass/http://localhost:8180/appB 
ProxyPassReverse/http://localhost:8180/appB 
ErrorLog logs/error_log 
CustomLog logs/access_log common 
</VirtualHost> 

感谢

+0

也许一个别名可以工作,我认为。 http://httpd.apache.org/docs/2.3/fr/mod/mod_alias.html – 2011-05-23 15:48:08

-- updated 

下面的工作很好...您可以添加其他应用程序与不同的上下文,在同一端口上运行。

<VirtualHost *:80> 
ServerName http://us14testServ/ 
ServerAlias us14testServ 
ProxyRequests Off 
ProxyVia On 

#app1 
ProxyPass /app1/ http://localhost:8180/app1/ 
ProxyPassReverse /app1/ http://localhost:8180/app1/ 

#app2 
ProxyPass /app2/ http://localhost:8180/app2/ 
ProxyPassReverse /app2/ http://localhost:8180/app2/ 

ErrorLog logs/error_log 
CustomLog logs/access_log common 
</VirtualHost> 
+0

如何指定在另一个端口上运行的应用程序? – 2016-04-21 11:26:53

,那么是什么你需要使用的是mod_rewrite

+0

抱歉不重定向,只需根据正在访问的应用程序将相应的请求定向到适当的上下文。 – Sai 2011-05-23 15:45:33