Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WildFly -> Undertow -> mapping subdomain to war file not working

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?

like image 601
cbl.adp Avatar asked Jun 27 '14 12:06

cbl.adp


2 Answers

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.

like image 186
Tomaz Cerar Avatar answered Sep 29 '22 03:09

Tomaz Cerar


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:

<jboss-web>
    <virtual-host>other-host</virtual-host>
</jboss-web>

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 and http://alias2:8080 as expected.

like image 37
Harald Wellmann Avatar answered Sep 29 '22 05:09

Harald Wellmann