• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Dynamic URIs Using one Context

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<note>
This question was also posted on the Tomcat Mailing List. Sorry if you're reading this twice...
</note>

We've been given a difficult problem to solve and I'm hoping that some help/insight is available on this mailing list.

We are an Application Service Provider (ASP) that has numerous clients with the number of clients increasing rapidly. All our clients use the same application but each client needs/wants a distinguishing element in the url to identify them to their users.

Here is our current setup:

Apache 2.2 with mod_jk sending requests to Tomcat 5.5. Struts 1.3.8 is our current web framework.

In our httpd.conf we have a different domain name for each client:

<VirtualHost *:80>
ServerName <client name 1>.<server name>.com
DocumentRoot <some directory>/<client name 1>.<server name>.com
</VirtualHost>

<VirtualHost *:80>
ServerName <client name 2>.<server name>.com
DocumentRoot <some directory>/<client name 2>.<server name>.com
</VirtualHost>

Then in our server.xml config file for Tomcat we only declare one Host element with a Context that has many Alias':

<Host name="<client name 1>.<server name>.com" appBase="webapps">
<Context path="/app" >
</Context>
<Alias><client name 2>.<server name>.com</Alias>
<Alias><client name 3>.<server name>.com</Alias>
...etc for each of our clients...
</Host>

So, what is the problem? Well, when we add a new customer we have to edit the httpd.conf, the server.xml, restart both applications, and add the new <customer>.<server name>.com to DNS (Usually, we have to wait until late into the evening to do these tasks). Our Client Services team want the ability to add customers without having to wait until we can restart our servers.

Is it possible to do the following with an Apache 2.2 and Tomcat 5.5 combination while having only ONE instance of the application only once loaded in Tomcat? (Meaning we do NOT want the application loaded by Tomcat x times, with x being the number of clients we have.)

<base name>.<server name>.com/<client name 1>/app
<base name>.<server name>.com/<client name 2>/app
<base name>.<server name>.com/<client name 3>/app

I'm not really the best with how the Context attribute works outside of having it placed in the server.xml. I've tried reading the documentation on Contexts at:
http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html
But, I find what is explained a tad bit confusing.

Here is one thread from the archives that explained our problem pretty well, but there never really was an answer on how to accomplish the task except "you're getting the right behavior with a 400 response":
http://marc.info/?l=tomcat-user&m=115602705505727&w=2

Finally, through some other research, it seems as though someone was trying to use mod_vhost_alias to accomplish the same thing.

Any thoughts or suggestions are welcome.

Thank you for your time.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of

<base name>.<server name>.com/<client name 1>/app
<base name>.<server name>.com/<client name 2>/app


I would do

<base name>.<server name>.com/app/<client name 1>
<base name>.<server name>.com/app/<client name 2>


That way nothing needs to be configured in httpd, nothing needs to be configured in Tomcat, and you have just a single web app. Everything related to keeping customer apart can be done inside of the web app. Case closed
 
Nathan Hook
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. So far, I'm really liking the way you think.

How would we get our application then to do our different mappings with Struts (1.3.8) then?

Please consider the following example...

<base name>.<server name>.com/app/<client name 1>/login.do
<base name>.<server name>.com/app/<client name 2>/login.do

What would a mapping like this in Struts look like?

Would we need to use filters to manipulate the request?

Thank you for the response. Your idea is a nice was of looking at the problem.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not too familiar with Struts, but usually it's configured to act on *.do URLs, no? So does it matter what comes before that? (I really don't know.)

Another way to handle the problem would be to have URLs like

<base name>.<server name>.com/app/?client=<client name>



You'd only need to do this for the start/login page, because after that you can remember the clientID in the server session (and you really need logins/passwords, or clients WILL hack their way into other clients app). Then all the *.do URLs that come after that don't need the client parameter - they look the same for all clients.
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic