You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shannon Scott <ss...@gwi.net> on 2003/03/09 13:39:41 UTC

Tomcat4 with Apache VirtualHost

Hello,
I have two domain names that I want to serve from one webserver.
I have set up DNS and now the apache is working fine.  The webserver 
serves up the html from the DocumentRoot for both domains, but Tomcat 
serves pages from the DocumentRoot of the first domains for both the domains.

How do I set up the server.xml for two domains using the same IP?
Do I have to use different IP addresses?

I followed a recent thread on this subject, but I guess my situation is not the same.

Attached and pasted below is a snip for my httpd.conf and server.xml.
Any help is greatly appreciated.
Thank You
Shannon

My system:
Linux RedHat 8.0
Apache 2.0.43
Tomcat 4.0.2
Mod_Jk Connector

httpd.conf snip:
NameVirtualHost  192.168.201.2
<VirtualHost 192.168.201.2>
        ServerAdmin     sscott@gwi.net
        DocumentRoot    /var/tomcat4/webapps/ROOT
       ServerName      host1.com
        ServerAlias     www.host1.com
        JkMount /servlet/* ajp13
        JkMount /*.jsp ajp13              
</VirtualHost>

<VirtualHost 192.168.201.2>
        ServerAdmin     sscott@gwi.net
        DocumentRoot    /var/tomcat4/webapps/host2
       ServerName      host2.com
        ServerAlias     www.host2.com
        JkMount /servlet/* ajp13
        JkMount /*.jsp ajp13        
</VirtualHost>

server.xml snip:
    <Engine name="Apache-Integrate" defaultHost="host1.com" debug="0">
      <Host name="host1.com" debug="0" appBase="webapps" unpackWARs="true">
          <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
          modJk="/etc/httpd/modules/mod_jk.so" jkDebug="info"
          workersConfig="/var/tomcat4/conf/jk/workers.properties"
          jkLog="/var/tomcat4/logs/mod_jk.log" />
          
         <Alias>www.host1.com</Alias>
      </Host>
      
      <Host name="host2.com" debug="0" appBase="webapps" unpackWARs="true">
          <Listener className="org.apache.ajp.tomcat4.config.ApacheConfig"
          modJk="/etc/httpd/modules/mod_jk.so" jkDebug="info"
          workersConfig="/var/tomcat4/conf/jk/workers.properties"
          jkLog="/var/tomcat4/logs/mod_jk.log" />
          
         <Alias>www.host2.com</Alias>
      </Host>