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

4
我在Jboss 6上运行了两个不同context的应用程序,它们共享同一个端口(8180)。我在机器端口80上运行了Apache。我需要根据所访问的应用程序来定向请求到适当的context。
我有一个dns条目-testServ14,它指向服务器IP。
更明确地说,应用程序应该通过以下URL访问: http://testServ14/appAcontext/ http://testServ14/appBcontext/ 在httpd-vhosts文件中,我应该使用virtualhost还是namevirtualhost指令?
我该如何实现这一点...
尝试了以下方法但未成功...
<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>

谢谢


也许使用别名可以解决问题。http://httpd.apache.org/docs/2.3/fr/mod/mod_alias.html - Brice Favre
2个回答

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

我该如何指定运行在另一个端口上的应用程序? - Ashwani Agarwal

1
如果您想从一个 URL 重定向到另一个 URL,则需要使用 mod_rewrite

抱歉,无法重定向请求,只能根据所访问的应用程序将请求直接传递到相应的上下文。 - Sai

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接