tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Single virtual tomcat application which serves multiple contexts
Date Fri, 20 Jan 2012 19:53:44 GMT
Egor Samarkhanov wrote:
> André,
> 
> Thanks for your notes! Please see my comments inline.
> 
> AW> Personal opinion:
> 
> AW> By putting some considerable effort into it, it is certainly possible to do something
like 
> AW> that, by rewriting URLs and/or proxying and/or making all your pages refer to
the context 
> AW> etc..
> 
> AW> But the question is : why ?
> AW> If
> AW> - you have many, many "clients"
> Yes, I do have really many clients, and hope to get even more.
> And in future I'd like to implement a failover solution with Tomcat
> cluster. If i have these many applications deployed, then they will
> be deployed on all nodes. I guess it would be much better if one
> node contains a single application which can serve any client
> (plus session replication). This way the cluster would be more
> effective.
> 
> AW> - or you application is so big that having multiple copies of it totally fills
your disk
> It's pretty big, but the disk space is not the real concern, but
> the memory. Many deployments of the same application consume lots of
> PermGen.
> 
> AW> - or your application for "client1" needs to share data with the application for
"client2"
> No, it doesn't.
> 
> AW> then it may be worth thinking about this.
> 
> AW> But otherwise, you probably would immensely simplify your life by using a separate
virtual 
> AW> host for each client, and have for each virtual host a separate appBase, in which
you just 
> AW> deploy a copy of your application.
> 
> By the way, I was thinking about virtual hosts, but I didn't find any
> solution yet to add new virtual hosts at runtime (to tomcat, or to apache
> httpd).
> 
> AW> Think of the security issues otherwise, to avoid one client being ever able to
access the 
> AW> data of another;
> 
> Good point.
> 
> AW> or think of what happens when one of these clients in the future asks you
> AW> for that little change just for him.. etc..
> 
> Yes, thinking about it all the time. But we didn't have such cases for
> 2 years, and if it happens - we would deploy the customized version to
> some other, separate environment.
> 
> 
> So, where do I start if I decide to go with the single virtual
> application? Did someone try doing such things?
> 
In that case, I would start with an Apache httpd front-end, connected to Tomcat via 
mod_proxy and mod_proxy_ajp, or via mod_jk.  You could then easily proxy any request to 
your single webapp running under Tomcat.
E.g.
http://front-end.company.com/client1/webapp -> tomcat:/single_webapp
http://front-end.company.com/client2/webapp -> tomcat:/single_webapp
...
http://front-end.company.com/clientn/webapp -> tomcat:/single_webapp
and use combinations of Proxy rules, Rewrite rules, SetHeaders rules etc.. to make sure 
that when your webapp returns pages, they correctly continue to refer to "client1", 
"client2" etc..
You just have to make sure then that your webapp always has enough information available,

to know for which client it is being called.

You can also do this with virtual hosts at the Apache level, all proxying to the same 
back-end tomcat.  And there are tricks at the Apache level to handle "dynamic virtual hosts".


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message