Search code examples
javajettyvirtualhostkaraf

Karaf: how to configure virtual hosts


How to set virtual hosts in Karaf?

Karaf has embedded Jetty, so i made context.xml with below content and have put this to /etc folder:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/</Set>
  <Set name="war"><SystemProperty name="jetty.home"/>/webapps/testWAB_war.war</Set>
  <Set name="virtualHosts">
    <Array type="java.lang.String">
      <Item>test.localhost</Item>
    </Array>
  </Set>
</Configure>

... but test.localhost:8181 brings to me 404.

Instructions in documentation about config file's location are unclear for me, could you tell me what did i wrong?

I think its about cfg file's location...


Solution

  • In case of Karaf the entire quest is a bit more complicated. You need to name connectors and then use pax-web speciffic manifest header to bind your module to it. More detailed description in blog post: http://notizblog.nierbeck.de/2013/01/bind-certain-web-applications-to-specific-httpconnectors/