Search code examples
http-redirectjbossforwardingmdm

Multiple context root for one app


We have renamed our context root used by Apple MDM, and are now faced with a need to be backward compatible with devices already enrolled. We are running JBoss

My first attempt was just to add a second module entry to application.xml with a new context root but the same war-file. I did not work, unless I made a copy of the war file with a new name. I really don't like this solution though it worked.

Instead I tried adding a Valve to the root app, which would then redirect for the old context roots to a new one. This also worked very well until a device made a POST, and then the posted binary content was lost.
The benefit of this solution would be that we could establish a new context root preparing it for dealing with MDM for Android and Windows Phone.

Could this be done with a forward, and how should it then be implemented?


Solution

  • In our company we solve these kind of problems with a proxy, so that the client doesn't really access directly to the JBoss server, but to the proxy, which redirects to the JBoss. We use an Apache Web Server with mod_proxy.

    So using mod_proxy for Apache, you'd set it up:

    # for the newcontext
    ProxyPass /newcontext http://jbosserver.com/newcontext
    ProxyPassReverse /newcontext http://jbossserver.com/newcontex
    # for the oldcontext
    ProxyPass /oldcontext http://jbosserver.com/newcontext
    ProxyPassReverse /oldcontext http://jbosserver.com/newcontext
    

    So if the name of the proxy is apacheserver.com, you could access to the service with: http://apacheserver.com/newcontext or http://apacheserver.com/oldcontext

    Another advantage of this architecture is that it gives you extra security since the clients doesn't access directly to the webserver. And of course you're not just limited to one context, you can create as many as you want in the apache.

    I hope it will help.