Hi Jeff,
Maybe I can increase my understanding here, since I not
that experienced with the Apache side.
The point of:
NameVirtualHost 111.22.33.44
<VirtualHost 111.22.33.44 >
ServerName www.foo.com
...
</VirtualHost>
was that mod_jk would identify the host as "www.foo.com"
for both Both "http://111.22.33.44/..." and
"http://www.foo.com/...". Thus, Tomcat could match it to a
single context identified by "www.foo.com". I can't claim to
understand the NameVirtualHost directive very well, but without
it, I believe that mod_jk would identify the host as
"111.22.33.44" instead of "www.foo.com" for
"httpd://111.22.33.44/...".
Obviously, I'm coming at this from the point of view of
keeping mod_jk and Tomat happy, and not necessarily what
is "normal" for Apache.
By the way, ApacheConfig in Tomcat 3.3 also supports the
following for "ServerAlias":
server.xml:
<Host name="www.foo.com" address="111.22.33.44" >
<Alias name="www.bar.com" />
<Context ... />
</Host>
which would generate conf/auto/mod_jk.conf:
NameVirtualHost 111.22.33.44
<VirtualHost 111.22.33.44 >
ServerName www.foo.com
ServerAlias www.bar.com
...
</VirtualHost>
Cheers,
Larry
> -----Original Message-----
> From: Jeff Kilbride [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 20, 2001 3:21 PM
> To: [EMAIL PROTECTED]
> Subject: Re: VHosts causing app to load twice
>
>
> Hi Larry,
>
> It doesn't really make sense to set up Name-based virtual
> hosting this way.
> In essence, your saying all requests for 111.22.33.44 should
> go to the same
> place as all requests for www.foo.com (in httpd.conf). In
> that case, I think
> you should stick with IP-based vhosts. Your Apache config
> would then be:
>
> <VirtualHost 111.22.33.44 >
> ........
> ........
> </VirtualHost>
>
> With this setup, the "host" header is ignored and all requests to
> 111.22.33.44, no matter what domain they come in on, will go
> to the right
> place -- from Apache's standpoint, I don't know if it's
> handled correctly in
> Tomcat. You should be able to set up your "Host" directive in
> server.xml to
> catch the IP Address and make it work that way, though.
>
> I think the real problem with Name-based vhosts comes when
> you're trying to
> point more than one domain name at the same Tomcat webapp:
>
> NameVirtualHost 111.22.33.44
>
> <VirtualHost 111.22.33.44>
> ServerName "foo.com"
> ServerAlias "www.foo.com"
> .......
> </VirtualHost>
>
> <VirtualHost 111.22.33.44>
> ServerName "bar.com"
> ServerAlias "www.bar.com"
> .......
> </VirtualHost>
>
> Now, if you want foo.com, www.foo.com, bar.com, and
> www.bar.com to all point
> at the same webapp, there's no way to do it without having
> four different
> instances of your webapp -- at least not in TC 3.2.x. I don't
> know about
> 3.3, but I think 4.0 has an "Alias" directive. I'm not sure
> if it's actually
> implemented, though.
>
> It may be kind of extreme to have different vhosts pointing
> at the same
> webapp, however I think it's pretty common to want foo.com
> and www.foo.com
> to point to the same place. It's really unfortunate that
> Tomcat (3.2.x)
> doesn't handle this without having to instantiate two
> different webapps. I'd
> be interested in fixing this in 3.2.x, if development wasn't already
> frozen...
>
> Thanks,
> --jeff
>
> ----- Original Message -----
> From: "Larry Isaacs" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, August 20, 2001 11:23 AM
> Subject: RE: VHosts causing app to load twice
>
>
> > In Tomcat 3.3 I have made changes to ApacheConfig.java to try
> > to address this. I think with Tomcat 3.2.2 you will need to
> > do the Apache part manually, which it seems you may already
> > be doing.
> >
> > I haven't done much with Vhosts on Apache beyond my tests
> > while playing with ApacheConfig. If I am in error, someone
> > let me know. It is my understanding that what you want is:
> >
> > server.xml
> > <Host name="www.foo.com" >
> > <Context ... />
> > </Host>
> >
> > httpd.conf or an include:
> > NameVirtualHost 111.22.33.44
> >
> > <VirtualHost 111.22.33.44 >
> > ServerName www.foo.com
> > ...
> > </VirtualHost>
> >
> > For me, this works under Tomcat 3.3. Both "http://111.22.33.44/..."
> > and "http://www.foo.com/..." come over to Tomcat as "www.foo.com".
> > I haven't tried this with Tomcat 3.2.x. I also haven't tried this
> > with *nix, just Win2k and Win98.
> >
> > One additional note. I had lots of trouble dealing with the "root"
> > contexts. Your httpd.conf below says the "root" context (i.e.
> > DocumentRoot) is at "/usr/local/apache/htdocs" and Tomcat thinks
> > it is at "/usr/local/apache/servlets". I think this situation is
> > ripe for problems. Not knowing your application, it is hard to say
> > what the best approach would be.
> >
> > Larry
> >
> >
> > > -----Original Message-----
> > > From: Steve Heard [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, August 20, 2001 1:44 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: VHosts causing app to load twice
> > >
> > >
> > > 3.2.2
> > >
> > >
> > >
> > >
> > > on 8/20/01 12:53 PM, Larry Isaacs at [EMAIL PROTECTED] wrote:
> > >
> > > > Which version Tomcat are you using? I have tried to deal with
> > > > this issue in Tomcat 3.3.
> > > >
> > > > Larry
> > > >
> > > >> -----Original Message-----
> > > >> From: Steve Heard [mailto:[EMAIL PROTECTED]]
> > > >> Sent: Monday, August 20, 2001 12:39 PM
> > > >> To: [EMAIL PROTECTED]
> > > >> Subject: VHosts causing app to load twice
> > > >>
> > > >>
> > > >> I have a servlet based application that needs to be accessed
> > > >> using both the
> > > >> the server IP address and the server domain name.
> > > >>
> > > >> The problem is that because I have two <host> entries
> for the same
> > > >> application tomcat "loads" them twice. Not only does this
> > > >> leave me with two
> > > >> instances of the servlets, but the ones I have marked to
> > > >> load on init have
> > > >> their code called twice which interferes with itself.
> > > >>
> > > >> I have tried every combination of VirtualHosts I can think of
> > > >> and always run
> > > >> into the issue of in order for Tomcat to recognize that it
> > > >> should handle the
> > > >> request to the servlet I have to add a <Host> entry in
> > > >> server.xml. If I
> > > >> leave out the entry for the IP address Apache passes the
> > > >> request along to
> > > >> tomcat fine, but then Tomcat doesn't recognize it. Likewise
> > > >> for the domain
> > > >> name.
> > > >>
> > > >> Any thoughts or help? I have included snippets of what I
> > > think are the
> > > >> relevant config files and how they should look.
> > > >>
> > > >> -Steve
> > > >>
> > > >> ----------------------------------------------
> > > >> From http.conf:
> > > >>
> > > >> ...
> > > >>
> > > >> NameVirtualHost 111.22.33.44
> > > >>
> > > >> <VirtualHost 111.22.33.44 >
> > > >> ServerName 111.22.33.44
> > > >> ErrorLog /usr/local/apache/logs/error_log
> > > >> DocumentRoot /usr/local/apache/htdocs
> > > >>
> > > >> JkMount /*.servlet ajp13
> > > >> </VirtualHost>
> > > >>
> > > >> <VirtualHost 111.22.33.44 >
> > > >> ServerName www.foo.com
> > > >> ErrorLog /usr/local/apache/logs/error_log
> > > >> DocumentRoot /usr/local/apache/htdocs
> > > >>
> > > >> JkMount /*.servlet ajp13
> > > >> </VirtualHost>
> > > >> ----------------------------------------------
> > > >>
> > > >> ----------------------------------------------
> > > >> From server.xml:
> > > >>
> > > >> ...
> > > >>
> > > >> <Host name="111.22.33.44" >
> > > >> <Context path="" docBase="/usr/local/apache/servlets" />
> > > >> </Host>
> > > >>
> > > >>
> > > >> <Host name="www.foo.com" >
> > > >> <Context path="" docBase="/usr/local/apache/servlets" />
> > > >> </Host>
> > > >>
> > > >> ...
> > > >> ----------------------------------------------
> > > >>
> > > >
> > >
> >
>