I have a server configuration with Apache http Server 2.2 with name based virtual hosts connected to separate Tomcat 7 virtual hosts using mod_jk connector.
Previously 2 Apache Virtual Hosts were successfully serving the separate applications from respective Tomcat Virtual Hosts, but recently when I tried to one more host to the configuration, the new host is not working.
Here is the host declaration in Tomcat's server.xml:
<Host name="localhost" appBase="webapps/localhost"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="xx1.com" appBase="webapps/xx1"
unpackWARs="true" autoDeploy="true">
<Alias>www.xx1.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="xx1_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="xx2.com" appBase="webapps/xx2"
unpackWARs="true" autoDeploy="true">
<Alias>www.xx2.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="xx2_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="xx3" appBase="webapps/xx3"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="xx3_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
Here's the Apache Virtual Hosts config:
<VirtualHost *:80>
ServerName xxx.com
ServerAlias *.xxx.com
JkMount /* newworker
</VirtualHost>
<VirtualHost *:80>
ServerName xx2.com
ServerAlias *.xx2.com
JkMount /* worker2
</VirtualHost>
<VirtualHost *:80>
ServerName xx1.com
ServerAlias *.xx1.com
JkMount /* worker1
</VirtualHost>
The Worker.properties file contents are:
worker.list=worker1, woker2, newworker
worker.worker1.type=ajp13
worker.worker1.host=xx1.com
worker.worker1.port=8009
worker.worker2.type=ajp13
worker.worker2.host=xx2.com
worker.worker2.port=8009
worker.newworker.type=ajp13
worker.newworker.host=xx3
worker.newworker.port=8009
And here is the mod_jk log:
[error] ajp_validate::jk_ajp_common.c (2748): worker newworker can't resolve tomcat address xx3
I think that the issue is with Tomcat, because when to access host xx3 from host-manager app, the application doesn't run. Whereas, xx1.com and xx2.com respond very well.
Note: xx1.com and xx2.com are public domains with their A records pointing to the server where applicatins are running whereas xx3 is a local doamin with no exclusive DNS Record except entry in hosts file.
After putting in a lot of time I have come to notice that worker.host parameter is resolving hostname based on DNS and not just the (virtual) hosts running in Tomcat. Though I find it very strange, it is the root cause of the problem.
Can someone help me configure the server for desired result.
Best Answer
Apache is unable to resolve the hostname
xx3
of the worker.You probably have hard-coded entries in
/etc/hosts
forxx1.com
andxx2.com
, but not forxx3
.You can find out by issuing:
and comparing that to:
Also note that: