Atlassian applications allow the use of reverse-proxies within our products, however Atlassian Support does not provide assistance for configuring them. Consequently, Atlassian can not guarantee providing any support for them.
If assistance with configuration is required, please raise a question on Atlassian Answers.
Purpose
This page describes a possible way to use NGINX to proxy requests for Confluence running in a standard Tomcat container. You can find additional documentation that explains how to use Apache mod_proxy for the very same purpose. For Confluence 6.0 or later you’ll need a version of NGINX that supports WebSockets (1.3 or later).
Solution
Configuring Tomcat
In this example, we’ll set up Confluence to be accessed at the address http://www.example.com/confluence (on standard HTTP port 80), while Confluence itself listens on port 8090 with context path /confluence.
For Confluence 6.0 or later we also need to include Synchrony, the service that powers collaborative editing, which listens on port 8091 with the context path /synchrony.
Set context path
Set your Confluence application path (the part after hostname and port) in Tomcat. Edit <CONFLUENCE-INSTALL>/conf/server.xml, locate the “Context” definition:
<Context path="" docBase="../confluence" debug="0" reloadable="false">
and change it to:
<Context path="/confluence" docBase="../confluence" debug="0" reloadable="false">
Restart Confluence, and check you can access it at http://example:8090/confluence
Set the URL for redirection
Next, set the URL for redirection. In the same <CONFLUENCE-INSTALL>/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"/>
And append the last line:
<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"
proxyName="www.example.com" proxyPort="80"/>
Configure NGINX
You will need to specify a listening server in NGINX, as in the example below. Add the following to your NGINX configuration:
For Confluence 6.0 and later:
server {
listen www.example.com:80;
server_name www.example.com;
location /confluence {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8090/confluence;
}
location /synchrony {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8091/synchrony;
proxy_http_version 1.1;