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

发布于 2024-11-09 00:51:56 字数 1023 浏览 0 评论 0原文

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

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

更清楚地说,应用程序应该可以通过类似于

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>

谢谢

I have two applications running on Jboss 6 with different context on same port (8180). I have Apache running on the machine port 80. I need to direct the request to appropriate context based on the application being accessed.

I have a dns entry - testServ14, which points to the server IP.

To be more clear, the applications should be accessible via urls something like

http://testServ14/appAcontext/

http://testServ14/appBcontext/

In httpd-vhosts file what should i be using virtualhost or namevirtualhost directives?

How can I achieve this..

Tried the following but did not work...

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

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟若柳尘 2024-11-16 00:51:56
-- 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>
-- updated

The following works nicely...you can add other apps with a different context,running on the same port.

<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>
花海 2024-11-16 00:51:56

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

If you want to redirect from one url to another, then what you need to use is mod_rewrite.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文