You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Curwen <gb...@gb-im.com> on 2003/09/16 00:34:57 UTC

RE: From which apache virtual host did a request come from?

Hrmm...   or not...
 
It must be an Apache setting, but hopefully someone here will know it.

If I specify something like this:

<VirtualHost 255.255.255.255>
     ServerName myfoo.com
     ServerAlias blah.myfoo.com
     ServerAias xyz.myfoo.com
     ServerAlias abc.myfoo.com
     DocumentRoot /home/webhome/myfoo
     #deny WEB-INF
     <Location "/WEB-INF">
         AllowOverride None
         deny from all
     </Location>
     JkMount /* tomcat1
     ErrorLog /var/log/myfoo/error_log
     CustomLog /var/log/myfoo/access_log combined
</VirtualHost>

Then within Tomcat, request.getServerName() always returns "myfoo.com"

If I separate each and every VirtualHost, then of course it works fine.
So blah, xyz and abc would all have their own VirtualHost, as opposed to
ServerAlias(es? ii? um?) Is there a way to get Apache to forward along
the requested AliasName as the ServerName ?





> -----Original Message-----
> From: Mike Curwen [mailto:gb_dev@gb-im.com] 
> Sent: Friday, August 15, 2003 8:44 AM
> To: 'Tomcat Users List'
> Subject: RE: From which apache virtual host did a request come from?
> 
> 
> Thanks Bill, that would work great. 
> 
> > -----Original Message-----
> > From: news [mailto:news@sea.gmane.org] On Behalf Of Bill Barker
> > Sent: Friday, August 15, 2003 12:50 AM
> > To: tomcat-user@jakarta.apache.org
> > Subject: Re: From which apache virtual host did a request come from?
> > 
> > 
> > It seems that I had a momentary lapse here.  A better
> > suggestion is to use request.getServerName();.  The 'host' 
> > header will also include the port number (if it's a 
> > non-standard port).
> > 
> > "Bill Barker" <wb...@wilshire.com> wrote in message
> > news:bhhl2q$rbi$1@sea.gmane.org...
> > > Have you tried request.getHeader("host"); ?
> > >
> > > "Mike Curwen" <gb...@gb-im.com> wrote in message
> > > news:004b01c36279$c5ddacf0$6f00000a@BALTHAZAR...
> > > > Our Tomcat has one <host>.  There is also only one webapp
> > to which
> > > > any request to the foo.com domain should go.
> > > >
> > > > Apache vhost blah.foo.com   -> TC default host, default webapp
> > > > Apache vhost abc.foo.com    -> TC default host, default webapp
> > > > Apache vhost xyz.foo.com    -> TC default host, default webapp
> > > >
> > > > The webapp parses  blah, abc and xyz.
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Angus Mezick [mailto:amezick@guidestar.org]
> > > > > Sent: Thursday, August 14, 2003 9:37 AM
> > > > > To: Tomcat Users List
> > > > > Subject: RE: From which apache virtual host did a request come
> > > > > from?
> > > > >
> > > > >
> > > > > Same deal.  Apache doesn't know anything about webapps.
> >  You just
> > > > > send requests for certain hosts to tomcat using
> > > > > workers2.properties.  Tomcat then uses its <host> entries to 
> > > > > decide which webapp get what.
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Mike Curwen [mailto:gb_dev@gb-im.com]
> > > > > > Sent: Thursday, August 14, 2003 10:27 AM
> > > > > > To: 'Tomcat Users List'
> > > > > > Subject: RE: From which apache virtual host did a
> > request come
> > > > > > from?
> > > > > >
> > > > > >
> > > > > > Actually, I was speaking about virtual hosts in Apache Web
> > > > > Server.  ;)
> > > > > >
> > > > > > A few more details:
> > > > > >
> > > > > > I have an application that parses the URI for some
> > parameters.
> > > > > > Basically the sponsors hate URLs that look like: 
> > > > > > http://www.foo.com/?foo=a&bar=b&baz=c
> > > > > >
> > > > > > So my fix was to parse the URI for the parameters in a known
> > > > > > order. http://www.foo.com/a/b/c
> > > > > >
> > > > > > They don't like this either. less typing, cleaner,
> > but *still*
> > > > > > not 'friendly'.  I might tell them that people using the web
> > > > > are used to
> > > > > > this sort of thing by now, but hey, they're the sponsors
> > > > > and they want
> > > > > > it different.
> > > > > >
> > > > > > So my last option is to flatten the parameters and use a
> > > > > > subdomain.
> > > > > >
> > > > > > http://abc.foo.com/
> > > > > > http://xyz.foo.com/
> > > > > >
> > > > > > So that's two virtual hosts in Apache, jk mounted 
> to a single
> > > > > > (default)
> > > > > > application on Tomcat.  That's possible, right?
> > > > > >
> > > > > >
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: John Turner [mailto:tomcat-user@johnturner.com]
> > > > > > > Sent: Thursday, August 14, 2003 8:59 AM
> > > > > > > To: Tomcat Users List
> > > > > > > Subject: Re: From which apache virtual host did a request
> > > > > come from?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > It's within <Host>.
> > > > > > >
> > > > > > > John
> > > > > > >
> > > > > > > Angus Mezick wrote:
> > > > > > >
> > > > > > > > Isn't there an <Alias> tag within <Context>?
> > > > > > > >
> > > > > > > >
> > > > > > > >>-----Original Message-----
> > > > > > > >>From: John Turner [mailto:tomcat-user@johnturner.com]
> > > > > > > >>Sent: Thursday, August 14, 2003 9:32 AM
> > > > > > > >>To: Tomcat Users List
> > > > > > > >>Subject: Re: From which apache virtual host did 
> a request
> > > > > > come from?
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>Mike Curwen wrote:
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>>1) Is it possible to mount several virtual hosts to
> > > > > the same web
> > > > > > > >>>application (the default one, as it happens)
> > > > > > > >>
> > > > > > > >>I think this is possible, though maybe not desired.
> > > > > > > >>
> > > > > > > >>You can see this with the manager app.  Setup a bunch
> > > > > of virtual
> > > > > > > >>hosts that have the same appBase, with Contexts 
> that have
> > > > > > > >>the
> > > > > > > same docBase,
> > > > > > > >>and you will be able to reach the same 
> application on any
> > > > > > > of the host
> > > > > > > >>names.  I determined that it was better to give 
> a separate
> > > > > > > appBase to
> > > > > > > >>each virtual host.
> > > > > > > >>
> > > > > > > >>If you mean setting separate appBase's for each virtual
> > > > > host, and
> > > > > > > >>still being able to access the same webapp (Context
> > > > > with the same
> > > > > > > >>docBase not
> > > > > > > >>a copy of the webapp in another docBase), I would
> > say "no".
> > > > > > >  It's at
> > > > > > > >>least a security risk.  Someone please correct me if I'm
> > > > > > > >>wrong.
> > 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>