Hosting multiple domains / websites with dm Server
I'm currently evaluating dm Server as a potential replacement server for our half-dozen websites currently running on Tomcat. However our scenario appears to not be handled well - or at all - by dm Server... so I'd like to know my evaluation is correct, and whether there are any plans to handle it.
In short, our scenario is that we host a few websites on a single server. The websites are different WARs but share common code in a common JAR. Each website has a different domain name, but they all run in the same instance of Tomcat.
dm Server should be ideal because it allows the common code to be put in an OSGi module shared by the multiple websites. But dm Server seems to lack Tomcat's ability to handle multiple websites / host names. dm Server allows a web module to be deployed to a particular context path, but not to a particular host. So we cannot have all our websites running in the one instance of dm Server.
In Tomcat, we configure server.xml like this to handle multiple hosts:
Code:
<Engine name="Catalina" defaultHost="www.example.com">
<Host name="www.example.com">
<Context docBase="/path/example.com" path=""></Context>
...
</Host>
<Host name="www.anothersite-example.com">
<Context docBase="/path/anothersite-example.com" path=""></Context>
...
</Host>
...
</Engine>
Is there any way of achieving a similar configuration with dm Server? As far as I can tell, the answer is no.
If the answer is no, then my question is: are there any plans to support multiple hosts in the future?
A workaround
There is a workaround that we are contemplating. I'm listing it here just in case readers of this message find it useful -- and if you have suggestions for improving the workaround, please chime in.
The workaround is to use Apache HTTPD to handle the multiple host names. The configuration is:
- Apache HTTPD 2.2 handles all incoming HTTP/HTTPS requests
- mod_rewrite converts host names into context paths for example www.example.com -> localhost/ExampleWeb and www.anothersite-example.com -> localhost/AnotherSiteExampleWeb
- mod_jk passes the requests to dm Server via AJP
- dm Server treats the multiple websites as being a single website, but with multiple context paths
There is one big limitation of this approach: Java assumes that the context path (such as /ExampleWeb) is part of the URL -- but in fact it's not. So java.net.URL and <c:url> etc will return invalid URLs like /ExampleWeb/path/index when what we wanted is /path/index