WildFly 8.1.0 Final Windows Server 2012 R2
I have two sub-domains pointing at this server, and I want requests to each sub-domain to trigger a different war file:-
webapp.domain1.com -> WildFly Server -> myapp1.war
test.domain2.net -> WildFly Server -> myapp2.war
My standalone.xml file is currently configured as follows based on advice received on the JBoss Developer site:-
<subsystem xmlns="urn:jboss:domain:undertow:1.1">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<host name="default-host" default-web-module="myapp1.war" alias="webapp.domain1.com"/>
<host name="other-host" default-web-module="myapp2.war" alias="test.domain2.net"/>
</server>
<servlet-container name="default">
<jsp-config/>
</servlet-container>
<filters>
<response-header name="server-header" header-value="WildFly/8" header-name="Server"/>
<response-header name="x-powered-by-header" header-value="Undertow/1" header-name="X-Powered-By"/>
</filters>
</subsystem>
Pointing a browser at webapp.domain1.com or test.domain2.net results in the request being sent to the WildFly server as expected, but the same war file (myapp1.war) is triggered in both cases.
Switching the 'name' values of the <host .../> elements as follows results in myapp2.war being called whichever URL is used:-
<host name="other-host" default-web-module="myapp1.war" alias="webapp.domain1.com"/>
<host name="default-host" default-web-module="myapp2.war" alias="test.domain2.net"/>
It looks like Undertow is only processing details of the "default-host" entry.
Can anyone here help with this please?
Failing that, does anyone know if (and how) WildFly can be used with Apache Web Server?
This is a bug in current undertow subsystem implementation. It only properly processes default-web-module for default host and doesn't even take it into account for non default hosts.
I created https://issues.jboss.org/browse/WFLY-3639 to track & fix it.
as a workaround until this is fixed add
jboss-web.xml
to WEB-INF
of your myapp2.war
with content:
<jboss-web>
<virtual-host>other-host</virtual-host>
<context-root>/</context-root>
</jboss-web>
which will tell server to what host & context root it should be bound to.