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@localhost
    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 webmaster@localhost
    ServerName jsp.example.com
    serveralias jsp.example.com
    JkMount /* worker1