This documentation relates to the latest version of Confluence.
If you are using an earlier version, please go to the documentation home page and select the relevant version.

Using Apache with mod_jk

All Versions
Click for all versions
Confluence 2.9 Documentation

Index

Introduction

The Apache web server is often used in front of an application server to improve performance in high-load environments. Mod_jk allows request forwarding to an application via a protocol called AJP. Configuration of this involves enabling mod_jk in Apache, configuring a AJP connector in your application server, and directing Apache to forward certain paths to the application server via mod_jk.

Mod_jk is sometimes preferred to mod_proxy because AJP is a binary protocol, and mod_jk supports fallback and load balancing. (Please note that you need a clustered license for Confluence to function properly in a load-balanced environment.)

The scope of this documentation is limited to configuring the AJP connector in Tomcat 5.x. Other application servers may support AJP connectors; please consult your application server documentation for instructions on how to configure it.

The configuration below assumes your Confluence instance is accessible on the same path on the application server and the web server. For example:

Externally accessible (web server) URL http://www.example.com/confluence/
Application server URL (HTTP) http://app-server.internal.example.com:8080/confluence/

The AJP connection of the application server is set to: app-server.internal.example.com:8009.

Configuring mod_jk in Apache

The standard distribution of Apache does not include mod_jk. You need to download it from the JK homepage and put the mod_jk.so file in your Apache modules directory.

# Put this after the other LoadModule directives
LoadModule jk_module modules/mod_jk.so

# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info

JkMount /confluence worker1
JkMount /confluence/* worker1

Configuring workers.properties

Create a new file called 'workers.properties', and put it in your Apache conf directory. (The path for workers.properties was one of the configuration settings above.)

worker.list=worker1

worker.worker1.host=app-server.internal.example.com
worker.worker1.port=8009
worker.worker1.type=ajp13

Tomcat 5.x configuration

In Tomcat 5, the AJP connector is enabled by default on port 8009. An absolutely minimal Tomcat server.xml is below for comparison. The relevant line is the Connector with port 8009 – make sure this is uncommented in your server.xml.

<Server port="8005" shutdown="SHUTDOWN">
  <Service name="Catalina">

    <!-- Define a HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" />

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" />

    <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost" appBase="webapps">
	<Context path="/confluence" docBase="/opt/webapps/confluence-2.2/confluence"/>
        <Logger className="org.apache.catalina.logger.FileLogger"/>
      </Host>
    </Engine>
  </Service>
</Server>

Points to note:

  • the Connector on port 8009 has protocol of "AJP/1.3". This is critical.
  • the Context path of the Confluence application is "/confluence". This must match the path used to access Confluence on the web server.
  • we recommend keeping your application Contexts outside the server.xml in Tomcat 5.x. The above example includes them for demonstration only.

Improving the performance of the mod_jk connector

The most important setting in high-load environments is the number of processor threads used by the Tomcat AJP connector. By default, this is only 15, and you should increase it to match Apache's maxThreads setting (256 by default):

<Connector port="8009" minProcessors="5" maxProcessors="256" protocol="AJP/1.3" />

Ensuring UTF-8 compatibility

If you have problems downloading attachments with non-ASCII characters in the filename, add the following to your Apache configuration:

JkOptions +ForwardURICompatUnparsed

And specify UTF-8 as the URIEncoding in the AJP connector configuration:

<Connector port="8009" protocol="AJP/1.3" URIEncoding="UTF-8" />

These settings are discussed further on Configuring Tomcat's URI encoding.

More information

The Tomcat JK website has complete documentation on workers.properties and Apache configuration. You can also find information there on how to use mod_jk with IIS.

Alternatives

If you're not happy with mod_jk, or find it too difficult to configure, you can:

  • use mod_proxy, which works with any application server, and together with mod_proxy_html allows complex URL rewriting to deal with different application paths on the web server and the application server.

Labels:

apache apache Delete
tomcat tomcat Delete
mod_jk mod_jk Delete
jk jk Delete
connector connector Delete
iis iis Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Feb 08, 2008

    Ludovic Lambert says:

    Configuring AJP forwarding with Apache 2.2.6, Tomcat 5.5.25 and modproxyajp Apa...

    Configuring AJP forwarding with Apache 2.2.6, Tomcat 5.5.25 and mod_proxy_ajp

    Apache HTTP Server 2.2 does not contain mod_jk anymore (at least in httpd-2.2.6.tar.gz). Used to use this module for fast fowarding, I built the .so from the latest tomcat-connectors-1.2.26-src
    No problem with the build, nor with the installation and configuration.

    Everything was working fine with Jira until I tried importing an XML workflow definition of 18557 characters with the help of the Workflow Import from XML feature (copy/paste the definition in the text area, therefore passing the workflow defintion through mod_jk). I received a nice "You must specify a file path or paste the XML definition into a text area" red message.
    After few thoughts, I tried removing mod_jk, and use direct Tomcat access, then mod_proxy, and everything were ok, the same workflow was successfully imported with the exact same operations.
    I figured out I did something wrong in my build, so I downloaded the built mod_jk-1.2.26-httpd-2.2.6.so. No way ! Still impossible to import my workflow
    Reaching some limits?

    1. Feb 11, 2008

      Mei Yan Chan says:

      Hi Ludovic, If this problem is still ongoing, please raise a support request in...

      Hi Ludovic,

      If this problem is still ongoing, please raise a support request in our system within the related product by attaching the associated config files (e.g. httpd.conf, server.xml) and we will look into it:

      Thanks.

      Regards,
      Mei

  2. Feb 26

    Darren Martz says:

    Is there a howto somewhere on setting up Confluence using Apache 2.2 (modcacheaj...

    Is there a how-to somewhere on setting up Confluence using Apache 2.2 (mod_cache_ajp) to Tomcat... but where Apache manages an SSL connection? I have been unable to get that working with mod_cache, with mod_jk, nor with mod_proxy_ajp. I am likely missing something basic and only need a nudge, but more documentation may be helpful here.

    1. Mar 04

      Choy Li Tham says:

      Hi Darren, Is there a howto somewhere on setting up Confluence using Apache 2....

      Hi Darren,

      Is there a how-to somewhere on setting up Confluence using Apache 2.2 (mod_cache_ajp) to Tomcat...

      Unfortunately, we do not have the Mod_cache_ajp documentation. However, if you are keen on using the mod_cache_ajp configuration, i would suggest you to post your queries to our forum or mailing list. From there, others developer/user who have experience in using the mod_cache_ajp should be able to share their ideas with you.

      Regards,
      Choy Li

  3. May 15

    Anonymous says:

    some one tell me&nbsp;how to configure the confluence with Apache Httpd 2.2.8

    some one tell me how to configure the confluence with Apache Httpd 2.2.8

    1. May 16

      Mei Yan Chan says:

      Hi, Did you manage to follow through the steps given in this doc? Or maybe you ...

      Hi,

      Did you manage to follow through the steps given in this doc? Or maybe you can try this:

      Besides, may I know which particular step you need assistance on?

      Regards,
      Mei

Add Comment