If we want to run independent sites for different domains, we can make use of a concept called “Virtual Hosting”. A servlet container is able to serve different applications depending on the requested domain.
== Configure Tomcat to serve multiple sites ==
* Create a folder called "sites" in Tomcat (so "sites" and "webapps" are contained within the same directory in the root of your Tomcat-installation). * Create a subfolder "yourdomain.org" in sites. * Copy a fresh (or already customized).war from a your application distributable to "sites/yourdomain.org" * Now edit Tomcat/conf/server.xml and add a second entry for a new virtual host right below the definition for the default host (which is the first entry below): <pre>... <!-- This entry is already contained in server.xml --> <!-- This entry adds a virtual host for yourdomain.org --> ...</pre> * Now restart Tomcat. * From now on Tomcat serves all requests for http://yourdomain.org/ from the ROOT-application contained in "sites/yourdomain.org".
== Configure Jetty to serve multiple sites ==
* Create a new folder called '''"sites"''' in the root directory of your Jetty installtion.
* Create a new folder '''jetty/sites/yourdomain.org/'''
* Copy your.war to '''jetty/sites/yourdomain.org/'''
* Create a file with the following content to '''jetty/conf/yourdomain.xml:'''
<pre>
/
/sites/yourdomain.org/your.war
www.yourdomain.org</pre>
* Now restart Jetty.
== Configure Apache as proxy for a servlet container ==
If you're running Apache in front of your servlet container, you'll need to configure Apache as proxy server for your servlet container as follows: <pre> Order Allow,Deny Allow from all ServerName yourdomain.org ServerAlias www.yourdomain.org ProxyPass / http://www.yourdomain.org:8080/ ProxyPassReverse / http://www.yourdomain.org:8080/</pre>
This way you can easily add additional sites as well. That’s easy, isn’t it?