Mantis - Resin
Viewing Issue Advanced Details
4720 minor always 08-18-11 13:02 08-25-11 15:47
ferg  
ferg  
normal  
closed 3.1.6  
fixed  
none    
none 4.0.22  
0004720: match web-app for /*/appname
(rep by Sachidanand Shukla)


Problem Description
Our application is configured to a web-app id="/app". All request with <domainName>/app/* are reaching the app and everything works great.
Now, we have a new brand which needed the URL to be <domainName>/<brandName>/app/*.

We tried various options ( details given below), but finally we had to configure two different webapps with different IDs, one with /app and one with /brandName but pointing to the same deployment directory ( via sym links).
With big down side of this solution was that the application now starts twice, once with /app context and then fro /brandName content, although it is the same app.

What we need?
Basically, all we need is to send all request with */app to the same app, and the URL should not change when it is received by the app, so that we can parse and take the brand name from the URL.
We have the configuration defined as;
      <web-app id="/app" document-directory="_ear_deployer/webapps/hi">
        <session-config cookie-domain=".foo.com">
          <enable-url-rewriting>false</enable-url-rewriting>
        </session-config>
      </web-app>
 <web-app id="/app" document-directory="_ear_deployer/webapps/cp"> // this directory is nothing but a symbolic link to /hi mentioned above.
        <session-config cookie-domain=".foo.com">
          <enable-url-rewriting>false</enable-url-rewriting>
        </session-config>
      </web-app>

We need to run some thing like:
   <web-app id=" * /app" document-directory="_ear_deployer/webapps/hi">

What we have tried so far?

We have tried two options which seemed to solve the problem and have one application support both cases, but both did not resolve the issue.

Approach 1: Used <web-app url-regexp= **>
We tried to use this option with configuring the app and using the regexp to configure the web app based on */app to go to same deployment directory.
Downside:
When specified by url-regexp, the application will be initialized at the first request. This is a big problem.

Approach 2: Used rewrite-dispatch
We used the rewrite-dispatch in resin.conf and it worked close to what we thought.

      <web-app id="/app" document-directory="deploy/hi">
        <session-config cookie-domain=".foo.com">
          <enable-url-rewriting>false</enable-url-rewriting>
        </session-config>
      </web-app>
<rewrite-dispatch>
<forward regexp="^/foo" target="/"/>
</rewrite-dispatch>

Problem with this approach when the request reached the app the portion before /app is removed. The browser still shows the URL as /foo/app but the application does not receive the /foo portion which is much needed to render the specific brand.

We need your help to make some suggestion so that we can run the same app and support both /app and /foo/app with one single instance of the application rendered from same deployment directory.


Notes
(0005467)
ferg   
08-25-11 15:47   
server/1hb1