Using Apache with mod_jk

  • The preferred configuration is Using Apache with mod_proxy. Together with mod_proxy_html this allows complex URL rewriting to deal with different application paths on the web server and the application server.
  • This page documents a configuration of Apache, rather than of Confluence itself. Atlassian will support Confluence with this configuration, but we cannot guarantee to help you debug problems with Apache. Please be aware that this material is provided for your information only, and that you use it at your own risk.

 

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 Confluence, 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 because some site administrators are more familiar with it than with mod_proxy.

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:8090/confluence/

1 Set the context path

Set your Confluence application path (the part after hostname and port) in Tomcat.  In this example the context path will be /confluence

Edit <installation-directory>conf/server.xml, locate the "Context" definition:

<Context path="" docBase="../confluence" debug="0" reloadable="true">

and change it to:

<Context path="/confluence" docBase="../confluence" debug="0" reloadable="true">

Restart Confluence, and check you can access it at http://example:8090/confluence.

2 Set the URL for redirection

First, set the URL for redirection. In your Confluence <installation-directory>conf/server.xml file, locate this code segment:

<Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                maxThreads="48" minSpareThreads="10"
                enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                protocol="org.apache.coyote.http11.Http11NioProtocol" />

Change the protocol to AJP and then add the proxyName, proxyPort and Scheme as follows:

<Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                maxThreads="48" minSpareThreads="10"
                enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                protocol="org.apache.coyote.ajp.AjpNioProtocol" 
                proxyName="www.example.com" proxyPort="80" scheme="http" />

If you're using SSL, change the scheme attribute to your Connector tag to scheme="https".

3 Configure 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.

Next, add the following in httpd.conf directly or included from another file:

# 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=8090
worker.worker1.type=ajp13

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 200, but you should increase it to match Apache's maxThreads setting (256 by default):

<Connector port="8090" minSpareThreads="5" maxThreads="256" protocol="org.apache.coyote.ajp.AjpNioProtocol" />

All the configuration parameters for the AJP connector are covered in the Tomcat documentation.

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

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.

Note: In IIS proxy server the maximum file upload is 30mb by default. Contact your server administrator if you need to upload a bigger file.

Last modified on Jul 14, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.