【问题标题】:Apache web server, multiple applications in different ports with on same serverApache Web 服务器,不同端口的多个应用程序在同一台服务器上
【发布时间】:2011-05-23 15:16:51
【问题描述】:

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

我有一个 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>

谢谢

【问题讨论】:

标签: apache


【解决方案1】:
-- 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>

【讨论】:

  • 如何指定在另一个端口上运行的应用程序?
【解决方案2】:

如果你想从一个url重定向到另一个,那么你需要使用mod_rewrite

【讨论】:

  • 抱歉没有重定向,只是根据正在访问的应用程序相应地引导请求到适当的上下文。
猜你喜欢
  • 2019-10-29
  • 2019-08-03
  • 2020-06-24
  • 2015-07-12
  • 1970-01-01
  • 2022-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多