Question

I have apache 2.2 with mod_jk sitting in front of two tomcat 6 servers. (all on the same box, one IP address) I'm trying to direct requests for aaa.test.com to one tomcat server and bbb.test.com to the other. I have two virtual hosts defined in the htpd.conf file. The problem I'm having is that all requests, regardless of the URL, go to the virtualhost that's defined first in the htpd.conf file. Either one will work fine if I have just that one defined.

The settings in the htpd.conf:

LoadModule jk_module modules/mod_jk.so
JkWorkersFile       "C:/Apache/Apache2.2/conf/workers.properties"
JkLogFile           "C:/logs/jkmount/mod_jk.log"
JkLogLevel          info

<VirtualHost *>
    ServerName    aaa.test.com
    JkMountFile   "C:/Apache/Apache2.2/conf/uriworkermap-aaa.properties"
</VirtualHost>

<VirtualHost *>
    ServerName    bbb.test.com
    JkMountFile   "C:/Apache/Apache2.2/conf/uriworkermap-bbb.properties"
</VirtualHost>

The workers.properties:

worker.list=aaa,bbb

worker.aaa.type=ajp13
worker.aaa.host=srv1.domain.int
worker.aaa.port=8109


worker.bbb.type=ajp13
worker.bbb.host=srv1.domain.int
worker.bbb.port=8109

If A is first I see this in the mod_jk.log:

[Fri May 04 15:35:03 2012] aaa aaa.test.com 0.003906

If I change the order:

[Fri May 04 15:53:43 2012] bbb bbb.test.com 0.011718

Thanks.

Was it helpful?

Solution

You probably want to use NameBasedVirtual Hosting:

So your Apache configuration should look like this:

NameVirtualHost *:80
<VirtualHost *:80>
ServerName    aaa.test.com
JkMountFile   "C:/Apache/Apache2.2/conf/uriworkermap-aaa.properties"
</VirtualHost>

<VirtualHost *:80>
ServerName    bbb.test.com
JkMountFile   "C:/Apache/Apache2.2/conf/uriworkermap-bbb.properties"
</VirtualHost>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top