wood burning stoves 2.0*
The moose likes Tomcat and the fly likes Name based virtual hosts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Name based virtual hosts" Watch "Name based virtual hosts" New topic
Author

Name based virtual hosts

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I'm trying to set up several virtual hosts that are based off of names in tomcat 5.0.28.

I'm using something like:
<Host name="www.someUrl.com" debug="0" appBase="someUrlwebapps" unpackWARs="true"><Alias>someUrl.com</Alias></Host>

Then I set up a directory similiar to webapps called someUrlwebapps and put it in the same directory as webapps.

When I direct a browser to www.someUrl.com I just get a blank screen (even though I have a ROOT directory under someUrlwebapps with pages in it).

I've tried moving the appbase to "webapps/someUrl" and setting that directory up like a normal webapp dir and I get the same problem.

Any idea what the problem is? It seems to know that it should be serving pages from a different directory... just its not either finding that directory... or something. Any help would be greatly appreciated.

-Tad
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

How are you resolving that URL?

Do you have it registered somewhere, your hosts file?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
The domain names are registered and I'm using 2mydns.com to have them redirected to my own IP address (all that works as expected). The incoming requests hit my router on port 80 (normal stuff) then I have my router forward the requests to port 8080 of my machine running tomcat. At first I thought maybe somewhere along the line a header was getting stripped and tomcat couldn't differentiate between requests. But I have it now to where the one domain I tried to setup on a separate host seems to redirect (I get a blank screen and not the "so you've installed tomcat" screen). I just wonder if its looking in the right directory still, or if I need to manually create a context for it. It did create directories off the working directory.

-tad
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I just started looking at my tomcat setup at work for the last project I worked on and remembered a few things. At home (the one I'm having issues with) the "manager" application wasn't working. I looked through the webapps directory and noticed it was "missing". I figured I accidentally deleted it. Thought I would copy it from work and use it. So I looked for it, and lo and behold its missing too. Actually the manager (and admin) application is located under the server directory. This got me to thinking that for whatever reason tomcat at home can't find the server/webapps directory and probably can't find the docbases for the other hosts either? I guess my question would then be how does it find the standard localhost docbase then?

I'm guessing I need to figure out how to set a tomcat home directory on my debian box. Well I hope that fixes it.

-Tad
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Well, I was wrong CATALINA_HOME is set (and set properly). So I'm lost why this isn't working.

The Manager and Admin apps (in the server/webapps directory) won't work either.

Just to try to figure out what else is going on, I changed the doc base for the localhost (default host) to something other than webapps (though I copied the same basic structure there). And I got a servlet error.

I'm running Tomcat 5.0.28 on debian, anyone have any idea whats causing this?

-Tad
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Ok... the manager/admin applications are working fine now... but still the virtual host is giving me fits...

Well now instead of a blank screen I'm getting an error (I think this is a step in the right direction):

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Ok... I figured out my error. I copied the web.xml file from the "default" install root directory into the root directory of the appbase of my other host =/ oops.
Now it works =)

-Tad
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Name based virtual hosts