...
top Anchor
This article shows how to configure Virtual Hosts in Apache Geronimo with Tomcat. By default, when you deploy and start an application in Geronimo, that application will be listening on every available host name. By configuring a virtual host you can make an application to listen on a specific host name or IP. The configuration steps described in this article are also valid when you are sharing a single IP among several host names.
...
To define the first HostGBean TomcatVirtualHost_1
add the following lines right after <module name="org.apache.geronimo.configs/tomcat/1.2/car">
.
...
To add the second HostGBean TomcatVirtualHost_2
add the following lines right after the first HostGBean. These two HostGBeans have been split so it is easier to identify them. The main difference between these two is the <attribute name="aliases">..,..</attribute>
line to define the aliases.
...
At this point you have successfully configured two different virtual hosts in Geronimo. Make sure you save the changes to the config.xml
file and start Geronimo.
...
For additional reference, this is the entire config.xml
with the two HostGBean already defined.
...
Declare the virtual host in the deployment plan
...
Assuming you followed the steps covered in the Quick start - Apache Geronimo for the impatient section you should have the following structure:
...
...
Open the geronimo-web.xml
file and edit the artifactId
and context-root
to make this deployment unique. Within the web-app
section add the host
attribute and specify the Virtual Host you want this application to listen, in this case virtualhost1.com
.
...
Save the changed to the geronimo-web.xml
file and generate a WAR file by typing the following command from the <app_home> directory:
...
We will now repeat this steps to create a second WAR. Edit once again the geronimo-web.xml
file and copy the content form the following example. Note that we are only changing the artifactId
, context-root
and host
.
...
...
Save the changed to the geronimo-web.xml
file and generate a second WAR file by typing the following command from the <app_home> directory:
...
You should get a successful confirmation message similar to this one:
No Format
Note that the deployer tool will not tell the Virtual Host where the application was deployed to, it will only tell the machine's defined host name. If you try to access that URL you should get a HTTP Status 404 - /hello_1, resource not available. That error message is a good sign since we deployed the application to a particular Virtual Host.
...
You should get a successful confirmation message similar to this one:
No Format
With the applications deployed the only thing left is to test them. Test hello_1 first, try to access the hosts names defined on the Geronimo server machine:
...