本文介绍了如何设置Jetty 6& Jboss 4.0.5虚拟主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一JBoss/Jetty服务器中部署了2个Web应用程序.在Jetty 5.1.14中,我有以下jetty-web.xml文件,该文件将其中一个应用程序配置为作为虚拟主机(在同一端口上)运行:

I have 2 webapps deployed in the same JBoss/Jetty server. In Jetty 5.1.14 I had the following jetty-web.xml which configured one of the apps to run as a virtual host (on the same port):

<Configure class="org.jboss.jetty.JBossWebApplicationContext"> 
  <Call name="addVirtualHost"><Arg>app2.localhost.com</Arg></Call> 
</Configure>

这工作得很好.不幸的是,它根本不适用于Jetty 6.1.17.首先,"JBossWebApplicationContext"现在似乎被称为"JBossWebAppContext",其次我可以找到的文档建议我应该使用如下所示的jetty-web.xml:

This worked perfectly fine. Unfortunately, it doesn't work with Jetty 6.1.17 at all. First of all, "JBossWebApplicationContext" seems to now be called "JBossWebAppContext", and secondly the documentation I could find suggests that I should be using a jetty-web.xml that looks like this:

<Configure class="org.jboss.jetty.JBossWebAppContext"> 
  <Set name="VirtualHosts"> 
    <Array type="java.lang.String"> 
      <Item>app2.localhost.com</Item> 
    </Array> 
  </Set> 
</Configure>

但这也不起作用.这两个webapp的部署没有错误,但是当我尝试使用虚拟主机名访问第二个应用时,它只是访问了第一个应用.这两个应用程序都在根上下文中(这是不可协商的).

But this doesn't work either. The two webapps deploy without error, but when I try to access the 2nd app under the virtual hostname, it just accesses the first app instead. Both applications are in the root context (this is not negotiable).

如何使虚拟主机正常工作?

How can I make virtual hosts work?

(顺便说一句,几天前,我有一个朋友在serverfault上发布了此消息,但没有人回答.)

(BTW, I had a friend post this on serverfault a few days ago, but nobody answered.)

推荐答案

如果将语法包含在每个Web应用程序的jetty6-web.xml中,则此语法有效.

This syntax works if you include it in the jetty6-web.xml for each web-app.

<Configure class="org.jboss.jetty.JBossWebAppContext">
  <Set name="VirtualHosts">
    <Array type="java.lang.String">
      <Item>host1.domain.com</Item>
      <Item>host2.domain.com</Item>
    </Array>
  </Set>
</Configure>

如果所有Webapp在同一容器中运行,则需要定义的虚拟主机.出于某种原因,使用虚拟主机部署一个WAR,而不使用虚拟主机部署一个WAR不起作用.

ALL webapps need the virtual hosts defined if they are running in the same container. For some reason deploying one WAR with virtual hosts and one without doesn't work.

这篇关于如何设置Jetty 6&amp; Jboss 4.0.5虚拟主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 16:35