Hosting Multiple Domains Using WildFly (Undertow)

For example, I have two domains ( app1.com , app2.com ) and two ears ( app1.ear , app2.ear ). Each EAR file consists of ejb.jar and web.war. Also, each WAR has a context root: / app1 or / app2 .

So, if I run WildFly, I will have two applications running on localhost: 8080 / app1 and localhost: 8080 / app2 .

How can I bind app1.com to localhost: 8080 / app1 and app2.com to localhost: 8080 / app2

As I understand it, I need to change the configuration of the Undertow subsystem in the standalone.xml file. I tried:

<server name="default-server"> <http-listener name="default" socket-binding="http"/> <host name="app1.com" default-web-module="app1.ear/web.war"/> <host name="app2.com" default-web-module="app2.ear/web.war"/> </server> 

but that will not work.

+5
source share
1 answer

Add WEB-INF / jboss-web.xml

with content

 <jboss-web> <context-root>app1</context-root> <virtual-host>app1.com</virtual-host> </jboss-web> 

and similarly for the second war.

+3
source

Source: https://habr.com/ru/post/1200669/


All Articles