Multiple Subdomains in Apache / Tomcat with mod_jk

最后都变了- 提交于 2019-12-20 01:58:20

问题


I am currently trying to setup two subdomains for two separate applications running from one Tomcat server and I am having a hard time getting it going.

Without the subdomains I am able to configure one VirtualHost with two mount points and able to get at the applications that way ( looks like http:// url/confluence ) but this is not optimal.

My set up is as follows:

  • Subdomain - youtrack.url.com
  • Subdomain - confluence.url.com
  • Tomcat7 running two war files with the context paths of /confluence and /youtrack
  • Apache 2 running mod_jk against tomcat instance

Here is my httpd.conf setup

JkWorkersFile /etc/httpd/conf/workers.properties
JkLogLevel info

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName youtrack.url.com
    ServerAlias www.youtrack.url.com
    JkMount /youtrack* tomcat
    DocumentRoot /var/www/html/youtrack
</VirtualHost>

<VirtualHost *:80>
    ServerName confluence.url.com
    ServerAlias www.confluence.url.com
    JkMount /confluence* tomcat
    DocumentRoot /var/www/html/confluence
</VirtualHost>

Here is my workers.properties

worker.list=tomcat

worker.tomcat.host=localhost
worker.tomcat.port=8009
worker.tomcat.type=ajp13

What appears to be happening is that I hit the DocumentRoot of each subdomain but when I remove the DocumentRoot it never makes it over to the Tomcat web app.

Looking for some help, Thanks.

Updated - here is the mod_jk log

[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1131): Attempting to map URI '/favicon.ico' from 2 maps
[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] find_match::jk_uri_worker_map.c (945): Attempting to map context URI '/confluence/=confluence' source 'JkMount'
[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] find_match::jk_uri_worker_map.c (945): Attempting to map context URI '/confluence=confluence' source 'JkMount'
[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] jk_translate::mod_jk.c (3723): no match for /favicon.ico found
[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] map_uri_to_worker_ext::jk_uri_worker_map.c (1131): Attempting to map URI '/favicon.ico' from 2 maps
[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] find_match::jk_uri_worker_map.c (945): Attempting to map context URI '/confluence/=confluence' source 'JkMount'
[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] find_match::jk_uri_worker_map.c (945): Attempting to map context URI '/confluence=confluence' source 'JkMount'
[Mon Aug 19 15:14:37.011 2013] [26577:139706593232864] [debug] jk_map_to_storage::mod_jk.c (3798): no match for /favicon.ico found

回答1:


Add this to your Apache web server config:

<VirtualHost youtrack.url.com:80>
    ServerName youtrack.url.com
    JkMount / tomcat
    JkMount /* tomcat
</VirtualHost>

<VirtualHost confluence.url.com:80>
    ServerName confluence.url.com
    JkMount / tomcat
    JkMount /* tomcat
</VirtualHost>

And this to your Tomcats server.xml:

For a single webapps directory (applications deployed with their domain names, see "docbase"):

<Host name="youtrack.url.com" appBase="webapps">
    <Context path="" docBase="youtrack"/>
</Host>

<Host name="confluence.url.com" appBase="webapps">
    <Context path="" docBase="confluence"/>
</Host>

For separate webapps directories (applications deployed as "ROOT"):

<Host name="youtrack.url.com" appBase="ABSOLUTE_PATH\youtrack-webapps" autoDeploy="true" unpackWARs="true" />
<Host name="confluence.url.com" appBase="ABSOLUTE_PATH\confluence-webapps" autoDeploy="true" unpackWARs="true" />


来源:https://stackoverflow.com/questions/18320286/multiple-subdomains-in-apache-tomcat-with-mod-jk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!