Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tomcat and Apache virtual hosts

Status
Not open for further replies.
Apr 27, 2006
9
CA
I've encountered a problem with my current setup, and am seeking input as to a solution.

Here is an overview of our setup, our problem, and an interim but imperfect solution we are using.

The setup: Tomcat, and apache using virtual hosts. The two virtual hosts are Dev and Test environments.

The problem: The application is named the same in both dev and test environments, meaning whichever virutal host one goes to, they're going to end up at the same application. Example: Application "UserManager".


The problem is, that Tomcat is told to load application "UserManager", and directs to the exact same application, regardless of which Virtual host the request is coming from. It would be nice if somehow Tomcat could discern which Virtual host the request is coming from and direct accordingly.

Our workaround:
In the virtual host used for development, we've included a line to rewrite the URL from to The war is named UserManagerDEV. It works, and allows us to direct to the appropriate WAR depending on which virutal host, but I would prefer a less kludgy situation.

Is there a way to get Tomcat to direct to a separate directory hierarchy, depending on the Virtual host used?

Is it possible/preferable to run two completely separate instances of Tomcat?

Is there another solution?

Any help appreciated,
Dan.
 
Have you considered using a VM (ie have two instances of the OS running, under different IPs) ?

Personally, we use completely different physical machines for dev, test, uat and live - which is the most ideal situation - but use VMWare for dev and test.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Thank you for the reply, Sedj.

I agree, that would be a nice way to have things set up, unfortunately, I do not have the luxury of changing the way things have been deployed. The situation I am faced with is of getting Tomcat+Apache to do what I want them to.

Considering the complexity and flexibility of these tools, I'm sure that it's possible... The question is how?

 
You could look into having mulitple <Host> entries in server.xml.

For example, one has a Host name of "dev" - and an appBase/docBase of one directory (ie not the default webapps directory), and another with "test" which has a docBase/appBase of another directory.

Then you can put the same webapp in these two directories, and have Apache redirect to the separate Hosts.

Or you could also have a look at multiple CATALINA_BASE setups - but I've never done that personally (though it may suit you).

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top