Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

=?iso-8859-1?Q?virtual hosting? anyone succeed??=

Michael C. Starkie

2003-12-20

Replies:

Has anyone succeeded in getting tomcat 5.0.16 set up for virtual hosting without using apache as a front end?

I'm trying to get one instance of tomcat to serve two domains on the same machine.

I have added two Host sections to server.xml and I see the following behavior when I access the sites from a browser running on the same host as tomcat:

http://localhost:8080 - default context
http://www.mydomain1.com - blank page
http://www.mydomain2.com - blank page
http://mydomain1:8080 - correctly runs the mydomain1 context
http://mydomain2:8080 - correctly runs the mydomain2 context

how do I get www.mydomain1.com and www.mydomain2.com to show the correct contexts?

from another host on my network the only context I can load is http://hostname:8080 to see the default context. All other contexts like http://www.mydomain1.com and http://domain1.com:8080 result in an "action cancelled" from ineternet explorer.

Here is an excerpt from server.xml:

 <Service name="Catalina">
   <Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" />
   <Connector port="8009" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3"/>
   <Engine name="Catalina" defaultHost="localhost" debug="0">
     <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
     <Realm className="org.apache.catalina.realm.UserDatabaseRealm" debug="0" resourceName="UserDatabase"/>
     <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
       <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt"/>
     </Host>
     <Host name="mydomain1.com" debug="0" appBase="webapps" unpackWARs="true">
       <Alias>www.mydomain1.com</Alias>
       <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="mydomain1." suffix=".log" timestamp="true"/>
       <Context path="" docBase="mydomain1" debug="0" reloadable="true"/>
     </Host>
     <Host name="mydomain2.com" debug="0" appBase="webapps" unpackWARs="true">
       <Alias>www.mydomain2.com</Alias>
       <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="mydomain2." suffix=".log" timestamp="true"/>
       <Context path="" docBase="mydomain2" debug="0" reloadable="true"/>
     </Host>
   </Engine>
 </Service>
©2008 junlu.com - Jax Systems, LLC, U.S.A.