- If the request points to the root context ("/"), you get the default welcome application. In this case the ROOT.war
- If the request points to a valid context (i.e, the context of a deployed web app), you get the response of this web app.
- If the request points to a invalid context, you get a 404
Besides the default virtual server, you can also define your own, by specifying a group of alias (domains) which will be handled in this virtual server.
For example, I have two web apps, /app1 and /app2 deployed, each one in its own context, among other webapps (/app3, /app4, etc.). The absolute URL would by:
- app1: https://domain1/app1
- app2: https://domain2/app2
- app3: https://domain3/app3
- app4: https://domain4/apps
There is a apache front-end configured with mod cluster. Each domain is a apache virtual host with forward the requests to the JBoss backends (a server cluster).
Now, I want to reconfigure this situation in order to get the following URLs:
- app1: https://myCommonDomain/
- app2: https://myCommonDomain/app2
- app3: https://domain3/app3
- app4: https://domain4/apps
JBoss configuration
The first step is to create a new virtual server in JBoss, in the web subsystem:<subsystem xmlns="urn:jboss:domain:web:1.5" default-virtual-server="default-host" native="false"> <configuration> <jsp-configuration development="true" check-interval="2000" /> </configuration> <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" /> <connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp" /> <virtual-server name="default-host" enable-welcome-root="true"> <alias name="localhost" /> <alias name="example.com" /> </virtual-server> <virtual-server name="myNewVirtualServer" default-web-module="app1.war"> <alias name="myCommonDomain"/> </virtual-server> </subsystem>
I created a virtual server named myNewVirtualServer, which default root will be app1.war (this is de runtime name of the deployment). This virtual server will be "listening" in myCommonDomain.
Web apps configuration
Inside app1 and app2, you need to include a jboss-web.xml file. In this file, each application declares its root context and references the virtual server created before.jboss-web.xml in app1.war:
<?xml version="1.0" encoding="UTF-8"?> <jboss-web> <context-root>/</context-root> <virtual-host>myNewVirtualServer</virtual-host> </jboss-web>
jboss-web.xml in app2.war:
<?xml version="1.0" encoding="UTF-8"?> <jboss-web> <context-root>/app2</context-root> <virtual-host>myNewVirtualServer</virtual-host> </jboss-web>
Web apps configuration
Finally, you need to declare a new apache virtual host for this domain.<VirtualHost *:443> ServerName myCommonDomain (...) </VirtualHost>
No hay comentarios:
Publicar un comentario