javajbosswarjboss-eap-6contextroot

Multiple context root for single war deployment jboss-EAP-6.1


In my Jboss-EAP-6.1 I have deployed a .war called 'myRealWebApp.war' I can access my app with this url - http://mywebsite.com/myRealWebApp

I want to configure my webapp 'myRealWebApp' with multiple context root. I mean if I access

http://mywebsite.com/appA
http://mywebsite.com/appB
http://mywebsite.com/appC

those 3 contexts 'appA','appB','appC' points to myRealWebApp.war (One single war deployed)

Is there anyway I can archive this?

Thanks.

Edit: Solution found: I added this code to my standalone-full.xml

   <subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
        <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
        <virtual-server name="default-host" enable-welcome-root="true">
            <alias name="localhost"/>
            <alias name="example.com"/>
            <rewrite name="rule-1" pattern="^/appA(.*)$" substitution="/myRealWebApp$1" flags="L"/>
            <rewrite name="rule-2" pattern="^/appB(.*)$" substitution="/myRealWebApp$1" flags="L"/>
            <rewrite name="rule-3" pattern="^/appC(.*)$" substitution="/myRealWebApp$1" flags="L"/>
        </virtual-server>
    </subsystem>

The key is the flags="L"

Thanks


Solution

  • You can achieve this by configuring an http server in front of the jboss (like an Apache server) and using redirect rulea to translate all the other urls to the one you have configured your application with. It might be that jboss also has a apache module for integration ,but the basic principle remains. Usually it is the recommendec way not to expose directly a jboss or other app server in production, but using http server in front of it ( you can serve static content from http server, you can balance requests, etc)