You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kalmn CHEUNG Ka Keung <ch...@chowsangsang.com> on 2009/06/26 09:40:35 UTC

apache tomcat connector multi domains problem

Hi All,

Linux version 2.6.8.1-12mdksmp
Sun JDK1.4.2
Apache-2.0.54 (domains: web.myserver.com, mobile.myserver.com)
jakarta-tomcat-connectors-jk2-2.0.4
jakarta-tomcat-5.0.28 X 2

I have an apache web server which is connecting 2 tomcat application
servers with apache-tomcat connector. Now I am going to register 2
domains, web.myserver.com and mobile.myserver.com, for the apache web
server. I have an idea as follows.

When the apache web server receive the request using web.myserver.com
domain, it will forward to tomcat 1 and if it receive the request using
mobile.myserver.com domain, it will forward to tomcat 2.

I have tried to edit the URI pattern on worker.properties file, but it
does not work.
[uri:/web.myserver.com/.*.jsp]
group=lb1
[uri:/mobile.myserver.com/.*.jsp]
group=lb2

[uri:*web.myserver.com/.*.jsp]
group=lb1
[uri:*mobile.myserver.com/.*.jsp]
group=lb2

[uri:http://web.myserver.com/.*.jsp]
group=lb1
[uri:http://mobile.myserver.com/.*.jsp]
group=lb2

Is it possible to do that? And how to config it if it is possible? Thanks!!!

Kalmn



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


Re: apache tomcat connector multi domains problem

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

Kalmn,

On 6/26/2009 3:40 AM, Kalmn CHEUNG Ka Keung wrote:
> Linux version 2.6.8.1-12mdksmp
> Sun JDK1.4.2
> Apache-2.0.54 (domains: web.myserver.com, mobile.myserver.com)
> jakarta-tomcat-connectors-jk2-2.0.4
> jakarta-tomcat-5.0.28 X 2

Note that these are ancient versions of Tomcat and mod_jk2 (mod_jk2
isn't even under development anymore: it's a dead project). You should
upgrade to Tomcat 5.5 or 6.0 when you have the time and upgrade to
mod_jk 1.2.28 /ASAP/.

> When the apache web server receive the request using web.myserver.com
> domain, it will forward to tomcat 1 and if it receive the request using
> mobile.myserver.com domain, it will forward to tomcat 2.

Easy: use 2 <VirtualHosts> in Apache httpd with each one configured to
proxy traffic to the proper Tomcat.

> I have tried to edit the URI pattern on worker.properties file, but it
> does not work.
> [uri:/web.myserver.com/.*.jsp]
> group=lb1
> [uri:/mobile.myserver.com/.*.jsp]
> group=lb2

Since mod_jk2 isn't supported anymore, I'm not going to try to support
it. What you want is easily doable using mod_jk:

workers.properties
- ------------------
worker.list=web, mobile

worker.web.type=ajp13
worker.web.host=localhost [or whatever your host is]
worker.web.port=8008      [or whatever your port is]

worker.mobile.type=ajp13
worker.mobile.host=localhost [or whatever your host is]
worker.mobile.port=8009      [or whatever your port is]

httpd.conf
- ----------

(Note these configurations need to be merged into your existing config:
they are not sufficient on their own)

NameVirtualHost *:80
JkWorkersFile /my/conf/dir/workers.properties
<VirtualHost *:80>
   ServerName web.myserver.com
   JkMount /*.jsp web
</VirtualHost>

<VirtualHost *:80>
   ServerName mobile.myserver.com
   JkMount /*.jsp mobile
</VirtualHost>

Your Tomcats' server.xml files need to have appropriate <Connector>
elements using the AJP13 connectors on ports 8008 or 8009 (depending on
which server is being used). Of course, use the ports you are already
using. 8008 and 8009 are only examples, provided by me since you didn't
post your actual configuration.

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

iEYEARECAAYFAkpFadcACgkQ9CaO5/Lv0PAkhgCgq774WLLNUsV+TbGRZp8CFy57
JRMAn0OsjNBA3cM5lLK2o0iraUCoA/h9
=2Kgr
-----END PGP SIGNATURE-----

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