tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Frieden <pfrie...@dChain.com>
Subject Re: Fw: Virtual Hosts and Context Path Question
Date Fri, 01 Dec 2000 20:25:36 GMT
We're doing essentially the same thing.  First thing you'll need to do
is upgrade to Tomcat 3.2.  There are lots of reasons other than the
virtual hosting support to do this.

If you use multiple <Host name="..."> entries where the name matches the
ServerName from httpd.conf, it should pick the proper host.  Each <Host>
can have its own context with path="".

Example httpd.conf:
<VirtualHost www.a.com>
        ServerName www.a.com
        DocumentRoot /opt/tomcat/webapps/www.a.com
        JkMount /servlet/* lbworker
        JkMount /*.jsp lbworker
</VirtualHost>

<VirtualHost www.b.com>
        ServerName www.b.com
        DocumentRoot /opt/tomcat/webapps/www.b.com
        JkMount /servlet/* lbworker
        JkMount /*.jsp lbworker
</VirtualHost>

Example server.xml:
<Host name="www.a.com">
	<Context path="" docBase="webapps/www.a.com" />
</Host>

<Host name="www.b.com">
	<Context path="" docBase="webapps/www.b.com" />
</Host>

I don't think there is any reason why this wouldn't work with mod_jserv,
but I've only tested it with mod_jk and ajp12.

Is this documented in the new user guides?  If not, it might be helpful
if it was.

Paul Frieden



> Shahed Ali wrote:
> 
> 
> -----Original Message-----
> From: Shahed Ali <shahed@enoor.com>
> To: tomcat-users@jakarta.apache.org <tomcat-users@jakarta.apache.org>
> Cc: tomcat-user@jakarta.apache.org <tomcat-user@jakarta.apache.org>
> Date: Friday, December 01, 2000 11:33 AM
> Subject: Virtual Hosts and Context Path Question
> 
> I am running Apache Stronghold with Virtual Hosts and Tomcat 3.1
> 
> I am using Named Hosts and have www.a.com and www.b.com both pointing
> to the same IP address.
> 
> 
> Now when I go to http://www.a.com I want my DoucmentRoot to point to
> /usr/local/jakarta-tomcat/webapps/A_APP/index.jsp
> But I also have to modify the Context Path = "" in server.xml to point
> to webapps/MYAPP
> 
> Now suppose I want http://www.b.com to point to
> /usr/local/jakarta-tomcat/webapps/B_APP/index.jsp, I would need
> to also set the Context path = "" ?
> 
> How can I go about doing this ?
> 
> 
>                                                 OR
> 
> 
> Or If I have virtual hosts using the same Tomcat Server, then do I
> need to keep all my jsp stuff in different contexts and
> Set up an alias in each virtual host = Context Path ?
> 
> So when I want to serve up jsp pages for site A I say
> http://www.a.com/siteAjsp/myapp.jsp
> And when I want to serve up jsp pages for site B I say
> http://www.b.com/siteBjsp/myapp.jsp
> 
> Where siteAjsp , siteBjsp etc all have to be unique
> aliases/context-paths combinations.
> 
> Eg
> 
> NameVirtualHost 192.168.5.100
> 
> <Virtual Host 192.168.5.100>
> ServerName www.a.com
> DocumentRoot "/home/a"
> Alias /siteAjsp "/usr/local/jakarta/tomcat/webapps/siteAjsp"
> ApJServMount /siteAjsp/servlet /siteAjsp
> <Location /siteAjsp/WEB-INF>
> .....
> </Location>
> </Virtual Host>                    <<<<<<<<<<<<
For this Host in
> server.xml Context path="/siteAjsp"  docbase = "webapps/siteAjsp"
> 
> <Virtual Host 192.168.5.100>
> ServerName www.b.com
> DocumentRoot "/home/a"
> Alias /siteBjsp "/usr/local/jakarta/tomcat/webapps/siteBjsp"
> ApJServMount /siteBjsp/servlet /siteBjsp
> <Location /siteAjsp/WEB-INF>
> .....
> </Location>
> </Virtual Host>                 <<<<<<<<<<<<
For this Host in
> server.xml Context path="/siteBjsp"  docbase = "webapps/siteBjsp"
> 
> Thanks
> Shahed

Mime
View raw message