User Tools

Site Tools


wiki:configuring_tomcat_apache_jk_virtual_host

Purpose:

1. Support dynamic domain name
2. Set up Apache and Tomcat, linked with mod_jk


Configuration file:

1. jk.conf

<IfModule jk_module>
   JkWorkersFile workers.properties
   JkShmFile /var/log/apache2/jk-runtime-status
   JkLogFile /var/log/apache2/mod_jk.log
   JkLogLevel error
</IfModule>

2. workers.properties

worker.list=worker1,status
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.status.type=status

3. virtual host

 <VirtualHost *>
    ServerAdmin webmaster[email protected]
    ServerName www.freecode.com.cn
    ServerAlias www.freecode.com.cn freecode.com.cn *.freecode.com.cn
    RewriteEngine on
    RewriteCond %{HTTP_HOST} [^.]+\.freecode\.com\.cn$
    # not rewrite www.freecode.com.cn, and
    # abc.freecode.com.cn is same as www.freecode.com.cn/abc
    RewriteCond %{HTTP_HOST} !^www\.freecode\.com\.cn$
    RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
    RewriteRule ([^.]+)\.freecode\.com\.cn(.*) /$1$2
 ...

4. jsp site

 <VirtualHost *>
    ServerAdmin [email protected]
    ServerName jsp.example.com
    serveralias jsp.example.com
    JkMount /* worker1
wiki/configuring_tomcat_apache_jk_virtual_host.txt · Last modified: 2008/11/20 15:04 by mirnshi