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?
I tested a setup similar to yours on Ubuntu 14.04 with WildFly 8.1.0.Final and Firefox 30, and for me, it works after adding a
WEB-INF/jboss-web.xml
to one my wars:I defined two different host aliases for the same IP in my /etc/hosts, and my browser gets redirected to the different web apps for
http://alias1:8080
andhttp://alias2:8080
as expected.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
toWEB-INF
of your myapp2.warwith content:
which will tell server to what host & context root it should be bound to.
default-host is the virtual host that will be used if an incoming request as no Host: header. So to get the requests to your other server, the request sent by the client should have "Host: other-host" in the request header.
A sample HTTP request from client looks like,
See if this works.