You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Harrison <da...@stress-free.co.nz> on 2007/03/22 21:34:46 UTC

Using the jk connector to join different tomcat contexts with discrete urls

Hi,
I am a little lost when it comes to linking Tomcat to Apache in  
circumstances where the urls to not map directly across to each other.

For example I have a Tomcat server with the following applications  
deployed:
TOMCAT/app1
TOMCAT/app2

I wish to map different Apache urls across to specific Tomcat  
contexts, for example:
http://app1.example.com/ to TOMCAT/app1.
http://app2.example.com/ to TOMCAT/app2

Using the jk connector documentation it is easy to setup the  
following direct mapping (with JkMount  /app1/* worker and JkMount  / 
app2/* worker):
http://www.example.com/app1 to TOMCAT/app1
http://www.example.com/app2 to TOMCAT/app2

But what I am after is a workers.properities or Apache directive that  
will allow the mapping to be indirect i.e. / -> /app1/ for each  
virtual host.

Is something like this possible using the same Tomcat host (and  
preferably workers.properties file)?

Regards,


David






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


Re: Using the jk connector to join different tomcat contexts with discrete urls

Posted by Erik Melkersson <er...@liu.se>.
Hi!

Actually I never got JkMount to work, so I would say something like:

<VirtualHost *:80>
     ServerName app1.example.com

     # you do not want to have a loop
     RewriteCond %{REQUEST_FILENAME} !^/app1/
     RewriteRule ^/(.*)$ /app1/$1 [PT]

   <Location /app1/>
     SetEnv JK_WORKER_NAME worker_for_app1
     SetHandler jakarta-servlet
   </Location>
</VirtualHost>

/Erik

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


Re: Using the jk connector to join different tomcat contexts with discrete urls

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Erik,

Erik Melkersson wrote:
> Hi! I wanted to do something similar. (but without the two virtual
> hosts).

It sounds like a solution might be something like this:

<VirtualHost *:80>
    ServerName app1.example.com

    RewriteRule ^(.*)$ /app1/$1 [PT]

    JkMount /* worker_for_app1
</VirtualHost>

<VirtualHost *:80>
    ServerName app2.example.com

    RewriteRule ^(.*)$ /app2/$1 [PT]

    JkMount /* worker_for_app2
</VirtualHost>

I always forget exactly what mod_rewrite does to the URL (the transform
is obvious, but I mean, how it affects processing), so you might have to
tweak the flags in order to get this to work properly.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGA8U+9CaO5/Lv0PARAl5RAKC4fj5lVb4ziz3dg9M5YTV6NSdfkQCgtHma
JguYoc7ahJ+eNJh1PRzVPxA=
=sGoJ
-----END PGP SIGNATURE-----

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


Re: Using the jk connector to join different tomcat contexts with discrete urls

Posted by Erik Melkersson <er...@liu.se>.
Hi!
I wanted to do something similar. (but without the two virtual hosts).

I did like this:

# The directory the user sees
RewriteRule ^/test/aaa/(.*) /tomcat-dir/$1 [PT]
RewriteRule ^/test/bbb/(.*) /tomcat-dir/stuff/$1 [PT]

# The directory tomcat serves the stuff on:
<Location /tomcat-dir/>
   SetEnv JK_WORKER_NAME workername
   SetHandler jakarta-servlet
</Location>


>> David Harrison wrote:
>>> I wish to map different Apache urls across to specific Tomcat contexts,
>>> for example:
>>> http://app1.example.com/ to TOMCAT/app1.
>>> http://app2.example.com/ to TOMCAT/app2

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


Re: Using the jk connector to join different tomcat contexts with discrete urls

Posted by David Harrison <da...@stress-free.co.nz>.
On 23/03/2007, at 8:49 AM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David,
>
> David Harrison wrote:
>> I wish to map different Apache urls across to specific Tomcat  
>> contexts,
>> for example:
>> http://app1.example.com/ to TOMCAT/app1.
>> http://app2.example.com/ to TOMCAT/app2
>
> This should be relatively straightforward.
>
> First, you'll need two Apache httpd virtual hosts configured.
>
> For each virtual host, just use the appropriate JkMount directives to
> send URI mappings "perhaps just /" to the proper worker.
>
> The only catch is the URIs themselves. If you want / to map to / 
> app1, it
> might be easiest to make "app1" into the ROOT application for that
> Tomcat instance, and use two separate Tomcat instances.

Part of this deployment question is getting away with not having to  
map a fixed ROOT application for the Tomcat server and instead rely  
on automated .war deployment into distinct contexts.

> I believe that using mod_proxy_ajp (instead of mod_jk), you can do  
> this
> very easily using something along the lines of
>
> # In VirtualHost app1.example.com
> ProxyPass / ajp13://localhost:8080/app1
>
> # In VirtualHost app2.example.com
> ProxyPass / ajp13://localhost:8080/app2

I had not heard of mod_proxy_ajp and it does look like it would do  
what I want when combined with mod_proxy_balancer.
The only problem is the production servers are Apache 2.0 and it  
looks like mod_proxy_ajp has been introduced in versions >2.1 :-(

I only wish that the standard mod_jk module would support such an  
activity as what is described, I'd prefer to tweak a few JkMount/ 
workers.properties settings than completely change the entire  
production environment :-)

Thanks for the information,


David


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


Re: Using the jk connector to join different tomcat contexts with discrete urls

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

David Harrison wrote:
> I wish to map different Apache urls across to specific Tomcat contexts,
> for example:
> http://app1.example.com/ to TOMCAT/app1.
> http://app2.example.com/ to TOMCAT/app2

This should be relatively straightforward.

First, you'll need two Apache httpd virtual hosts configured.

For each virtual host, just use the appropriate JkMount directives to
send URI mappings "perhaps just /" to the proper worker.

The only catch is the URIs themselves. If you want / to map to /app1, it
might be easiest to make "app1" into the ROOT application for that
Tomcat instance, and use two separate Tomcat instances.

I believe that using mod_proxy_ajp (instead of mod_jk), you can do this
very easily using something along the lines of

# In VirtualHost app1.example.com
ProxyPass / ajp13://localhost:8080/app1

# In VirtualHost app2.example.com
ProxyPass / ajp13://localhost:8080/app2

I believe that this is trickier when using mod_jk. This is one of the
only situations where I've found that mod_proxy_ajp is nicer than mod_jk.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGAuvi9CaO5/Lv0PARAuSMAJ9iKxqvmrhTpf3SvH8JtW4cqp/z8QCeNfti
oU9fjkAebvdwIu263QmjJQY=
=BuiT
-----END PGP SIGNATURE-----

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