GPN
GPN

Reputation: 53

Hosting multiple virtual-hosts/domains in wildfly

This is related to two posts -

Hosting multiple domains with WildFly (Undertow),

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

The workaround with creating/editing jboss-web.xml does not seem to be working.

I tried this workaround for my scenario where two virtual hosts are served exactly with the same WAR files, with no context-root configuration.

In wildfly/standalone/configuration/standalone.xml:

<host name="domain1" alias="domain1.rootdomain.com">
    <location name="/" handler="welcome-content"/>
    <filter-ref name="server-header"/>
    <filter-ref name="x-powered-by-header"/>
</host>
<host name="domain2" alias="domain2.rootdomain.com">
    <location name="/" handler="welcome-content"/>
    <filter-ref name="server-header"/>
    <filter-ref name="x-powered-by-header"/>
</host>

In jboss-web.xml:

<jboss-web>
  <virtual-host>domain1</virtual-host>
  <virtual-host>domain2</virtual-host>
</jboss-web>

During deploy/redeploy Wildfly complains that already one virtual-host tag was processed and the deployment/redeployment fails.

Is there any other solution for this problem?

Upvotes: 2

Views: 8929

Answers (1)

Korvin
Korvin

Reputation: 35

I had the same problem for long time ago. My solution was to "merge" two host configurations in a single one, like:

<host name="domains1and2" alias="domain1.rootdomain.com, domain2.rootdomain.com">
    <location name="/" handler="welcome-content"/>
    <filter-ref name="server-header"/>
    <filter-ref name="x-powered-by-header"/>
</host>

And then in jboss-web.xml:

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

Upvotes: 1

Related Questions