This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Virtual Hosting on Tomcat 7 - always route to the default host Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Virtual Hosting on Tomcat 7 - always route to the default host" Watch "Virtual Hosting on Tomcat 7 - always route to the default host" New topic
Author

Virtual Hosting on Tomcat 7 - always route to the default host

Yair Harel
Greenhorn

Joined: Aug 20, 2011
Posts: 2
Hello,

I'm trying to configure virtual hosts on my tomcat 7 installation.
No matter what I did, tomcat route all the request to the "defaulthost" property which I defined in the server.xml file.

Here is the server.xml file, as you can see all the requests will be route to the "api" vhost.

<Engine name="Catalina" defaultHost="api">

<Realm className="org.apache.catalina.realm.LockOutRealm">

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="api" appBase="api"
unpackWARs="true" autoDeploy="true">

<Alias>api.tl.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />

</Host>
<Host name="site"
unpackWARs="true" autoDeploy="true">
<Alias>tl.com</Alias>
<Alias>www.tl.com</Alias>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="author_log." suffix=".txt"
timestamp="true"/>
</Host>
<Host name="tl" appBase="tl"
unpackWARs="true" autoDeploy="true">
<Alias>tl.tl.com</Alias>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="author_log." suffix=".txt"
timestamp="true"/>
</Host>
<Host name="dev" appBase="dev"
unpackWARs="true" autoDeploy="true">
<Alias>dev.tl.com</Alias>
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="author_log." suffix=".txt"
timestamp="true"/>
</Host>
</Engine>


I also define to each vhost the docBase directory, for example :

yair@ubuntu:~/tomcat$ cat conf/Catalina/site/ROOT.xml
<Context path="" docBase="/servers/yair/tomcat/site/ROOT" />

I'm using apache-tomcat-7.0.20 on ubuntu.

Appreciate any help !

Thanks,
Yair


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Virtual Hosting on Tomcat 7 - always route to the default host
 
Similar Threads
apache2/tomcat5/mod_jk2 problem
virtual hosts in stand alone tomcat
Enable Logging in Tomcat
Weird result of server.xml for Virtual Host
Why my application on Tomcat works only with localhost?