Web server

Taggings:

ProgrammingLanguage:

Technology:

How to correctly configure a Jetty Servlet container to be used through an Apache Web server via mod_jk

Here are the basic/central steps to take.

  1. Install mod_jk (and mod_rewrite).
    sudo aptitude install libapache2-mod-jk libapache2-mod-rewrite
  2. Adjust jk.conf.
    sudo vi /etc/apache2/mod-available/jk.conf

    JkWorkersFile /etc/apache2/workers.properties
    JkLogFile /var/log/apache2/jk.log
    JkLogLevel error
    JkMount /jetty/* jetty
    JkOptions +ForwardURIEscaped
  3. Add JK instance to workers.properties.
    sudo vi /etc/apache2/workers.properties

    worker.list=jetty
    worker.jetty.port=8009
    worker.jetty.host=localhost
    worker.jetty.type=ajp13
  4. Enable mod_jk.
    sudo a2enmod jk
  5. Enable mod_rewrite.
    sudo a2enmod rewrite
  6. Add virtual host conf.
    sudo vi /etc/apache2/sites-available/app.example.com

    <VirtualHost *>
    ServerName app.example.com
    ...
    RewriteEngine on
    RewriteRule ^(.*) /jetty/app$1 [L,PT]
    ...
    </VirtualHost>
  7. Enable site.
    sudo a2ensite app.example.com
  8. Reload Web Server conf.
    sudo /etc/init.d/apache2 reload

Some mod_jk properties are not supported by resp. not working right with Jetty (as opposed to Tomcat), e.g.:
socket_timeout, socket_keepalive, connect_timeout

Have fun! :-)

Subscribe to Web server