How do I set up Jetty 6 & Jboss 4.0.5 virtual hosting?

允我心安 提交于 2020-01-02 10:19:31

问题


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>

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>

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?

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


回答1:


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>

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.



来源:https://stackoverflow.com/questions/854467/how-do-i-set-up-jetty-6-jboss-4-0-5-virtual-hosting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!