Proxying Atlassian server applications with Apache HTTP Server (mod_proxy_http)

Atlassian applications allow the use of reverse-proxies with our products, however Atlassian Support does not provide assistance for configuring them. Consequently, Atlassian cannot guarantee providing any support for them.

If assistance with configuration is required, please raise a question on Atlassian Answers.


This page explains how to establish a network topology in which Apache HTTP Server acts as a reverse proxy for Atlassian server applications. The page has been written as a recipe for success – we recommend you follow it step by step.  

 You might consider using a reverse proxy when you want users to access the Atlassian applications: 

  • at their own domains, such as    http://my<atlassianapp>.com/
  • at subdomains of another domain, such as http://my<atlassianapp>.ourcompany.com/
  • at context paths on either a domain or subdomain, such as http://ourcompany.com/my<atlassianapp>
  • on different HTTP ports, such as 9800, 9850, etc.

For more complex scenarios, you can refer to the Apache HTTP Server documentation, consult with an Apache specialist in your organisation, ask a question on Atlassian Answers or contact one of our Atlassian Experts.

The instructions on this page apply to the following Atlassian server applications:

  • JIRA server applications (JIRA Software Server, JIRA Core, JIRA Service Desk)
  • Confluence Server (there are some additional steps and examples in this guide for Confluence 6.0 and later)
  • Bamboo Server
  • Bitbucket Server
  • FishEye
  • Crucible
  • Crowd

In the examples that follow on this page, <atlassianapp> refers to the name of any of the Atlassian server applications above.

 

Atlassian server applications bundle a web server, which allows them to run without needing a proxy server. For most Atlassian applications, the bundled web server is Apache Tomcat  (FishEye and Crucible use  Jetty ). Consequently, you need to configure both Tomcat (or Jetty if using FishEye or Crucible) and Apache HTTP Server when proxying an Atlassian application.

On this page:

Prerequisites

You'll need the following:

Apache version 2.2 or 2.4 installed

You may find it helpful to refer to the Apache HTTP Server Documentation, which describes how you can control Apache HTTP Server by editing the httpd.conf file. The section on Apache Module mod_proxy is particularly relevant. Note that any changes you make to the httpd.conf file will only be effective after restarting Apache HTTP Server. (Applications that use Synchrony, e.g. Confluence 6.0, must use Apache 2.4.10 and up.)

DNS entries in place and configured for your domains

You should check, perhaps with your system or network administrator, whether the current DNS configuration for your organization will need changes to support the proxy topology you wish to set up.

The Atlassian applications installed, and accessible through a web browser

Install the Atlassian applications in the usual way.

Part A. Configure the Atlassian applications

This section describes how to configure the Tomcat (or Jetty) web server bundled with each Atlassian application to run behind a reverse proxy.

1. Stop the Atlassian applications

Stopping the application also stops Tomcat.

 

Click for stopping information...
JIRA applications

Use these commands from the JIRA installation directory:

  • bin/start-jira.sh
  • bin/stop-jira.sh

On Windows, use:

  • bin\start-jira.bat
  • bin\stop-jira.bat

See also JIRA application Startup and Shutdown Scripts.

Confluence

Use these commands from the Confluence installation directory:

  • bin/start-confluence.sh
  • bin/stop-confluence.sh

On Windows, use:

  • bin\start-confluence.bat
  • bin\stop-confluence.bat

See also Starting Confluence Automatically on System Startup.

Bamboo Server

Use these commands from the Bamboo installation directory:

  • bin/start-bamboo.sh
  • bin/stop-bamboo.sh

On Windows, use:

  • bin\start-bamboo.bat
  • bin\stop-bamboo.bat

See also Running Bamboo as a service.

Bitbucket Server

See Starting and stopping Bitbucket Server.

FishEye

Use these commands from the FishEye installation directory:

  • bin/start.sh
  • bin/stop.sh

On Windows, use:

  • bin\start.bat
  • bin\stop.bat

See also Running FishEye as a Windows service.

Crucible

Use these commands from the Crucible installation directory:

  • bin/start.sh
  • bin/stop.sh

On Windows, use:

  • bin\start.bat
  • bin\stop.bat

See also Running Crucible as a Windows service.

Crowd

Use these commands from the Crowd installation directory:

  • /start_crowd.sh
  • /stop_crowd.sh

On Windows, use:

  • \start-crowd.bat
  • \stop-crowd.bat

See also Installing Crowd as a Windows Service.

2. Set the context path

This step is only required if you want an application to be accessed on a context path, such as http://ourcompany.com/<contextpath>. If this is not required, you can skip this step.

FishEye and Crucible

If you're proxying FishEye or Crucible, configure the web context path for Jetty from the admin area. See Configuring the FishEye web server.

JIRA applications, Confluence, Bitbucket Server, Bamboo

If you're proxying any of these Atlassian server applications, configure the context path in the Tomcat server.xml file as follows.

 

Click for server.xml location info...

The location of your server.xml file depends on your application, operating system, and installation location. 

Common default installation locations for Atlassian applications are:

  • Linux: /opt/atlassian/<application-name>
  • Windows: C:\Program Files\Atlassian\<application-name>
  • Windows: C:\Atlassian\<application-name>

Locations in Atlassian application's folder structure:

Application server.xml location
Bamboo <install-path>/conf/
Confluence <install-path>/conf/
Crowd <install-path>/apache-tomcat/conf/
Crucible As for FishEye.
FishEye The FishEye configuration file is config.xml, see Configuring the FishEye web server and How to enable FishEye/Crucible to listen to web requests on additional ports.
JIRA applications <install-path>/conf/
Bitbucket Server 5.0

N/A, replaced by <Bitbucket home directory>/shared/bitbucket.properties

Please read through Migrate server.xml customizations to bitbucket.properties

Bitbucket Server 4.0 – 4.14 <Bitbucket home directory> /shared/server.xml
Stash 3.8 – 3.11

<Stash home directory>/shared/

If you are on any of these later releases but your server.xml does not exist in the directory above, it means that you are running from the <install-path>/conf/server.xml.

We recommend that you copy <install-path>/conf/server.xml into <Stash home directory>/shared/ that way you won't need to worry about this when you upgrade your instance.


Stash 3.7 and earlier <install-path>/conf/

<install-path> refers to where the application was installed on your system.

 

If you are configuring Bitbucket Server 5.0

As of Bitbucket Server 5.0, you can't configure any Tomcat connectors directly, therefore the configurations in this section only apply for Bitbucket server 4.14 or earlier.

server.xml configurations have been replaced by <Bitbucket home directory>/shared/bitbucket.properties

Please read through Moving Bitbucket Server to a different context path for Bitbucket Server 5.0 and later specific instructions.

 

 

In the Tomcat server.xml configuration file for all applications except Crowd, locate the Context directive that looks like this:

<Context path="" docBase="${catalina.home}/atlassian-<atlassianapp>" reloadable="false" useHttpOnly="true">

Change the directive to add the new context path:

<Context path="/<contextpath>" docBase="${catalina.home}/atlassian-<atlassianapp>" reloadable="false" useHttpOnly="true">

Use your own value for <contextpath>. Typically, each application would use a different context path.

It is important that the path value has a leading forward slash (/) like path="/<contextpath>" rather than path="<contextpath>".

Use these instructions to Removing the 'crowd' Context from the Application URL.

3. Configure the Connector directive

If you're using FishEye or Crucible, configure the proxy host, proxy scheme and the proxy port from the Admin area. See Configuring the FishEye web server.

If you are configuring Bitbucket Server 5.0

As of Bitbucket Server 5.0, you can't configure any Tomcat connectors directly, therefore the configurations in this section only apply for Bitbucket server 4.14 or earlier.

server.xml configurations have been replaced by <Bitbucket home directory>/shared/bitbucket.properties

Please read through Migrate server.xml customizations to bitbucket.properties to check the corresponding properties and and to translate the configuration below. After finishing the mapping to bitbucket.properties go to Part B. Configure Apache HTTP Server.

If you're using any of the other Atlassian server applications, configure the Connector directive as follows.

For each application, find the normal (non-SSL) Connector directive in the Tomcat server.xml file, and add the scheme,  proxyName, and proxyPort attributes inside the Connector directive, as below. Use the default values for the other attributes, including for  port , unless you have a particular reason to change them, and use your own domain name for the proxyName value:

<Connector port=<default>
	maxThreads=<default>
    minSpareThreads=<default>
    connectionTimeout=<default>
    enableLookups=<default>
    maxHttpHeaderSize=<default>
    protocol=<default>
    useBodyEncodingForURI=<default>
    redirectPort=<default>
    acceptCount=<default>
    disableUploadTimeout=<default>
	proxyName="<subdomain>.<domain>.com"
	proxyPort="80"
	scheme="http"/>

Note that the proxyName parameter should be set to the FQDN that Apache HTTP Server will be configured to serve. This is the address a user would type into their browser to access the application. For example:

  • use <atlassianapp>.ourcompany.com to access the application at a sub-domain like http://<atlassianapp>.ourcompany.com
  • use ourcompany.com to access the application at a context path like http://ourcompany.com/<atlassianapp>. In this case, the context path should not be included in the proxyName parameter, and you would have already set the Context directive in step 2 above.

For more information about configuring the Tomcat Connector, refer to the Apache Tomcat 7.0 HTTP Connector Reference.

 

Part B. Configure Apache HTTP Server

Atlassian recommends that you use the mod_proxy module, which implements a proxy, gateway or cache for Apache while also allowing multiple virtual hosts on a single client.

For more information about mod_proxy see:

1. Enable the mod_proxy modules in Apache

If necessary, enable the required modules in Apache as follows:

 

Expand to see Debian/Ubuntu instructions

Debian and Ubuntu distributions refer to Apache as 'Apache2', with the apache2.conf configuration file stored in the /etc/apache2/ directory.

You can enable mod_proxy and supporting modules from the command line as follows:

$ sudo a2enmod proxy_http
Considering dependency proxy for proxy_http:
Enabling module proxy.
Enabling module proxy_http.
To activate the new configuration, you need to run:
  service apache2 restart
If you're using Confluence 6.0 or later ...

If you're using Confluence 6.0 or later with Synchrony (required for collaborative editing), you'll need to use Apache 2.4, and also enable the mod_proxy_wstunnel and mod_rewrite modules:

$ sudo a2enmod proxy_wstunnel
$ sudo a2enmod rewrite
Expand to see Fedora and CentOS instructions

Fedora and CentOS 7 refer to Apache as 'httpd' and enable the mod_proxy modules by default. If necessary, you can find the configuration files in the /etc/httpd/conf/, /etc/httpd/conf.d/ and /etc/httpd/conf.modules.d/ directories.

For more information about how the configuration files are processed, see:

If you're using Confluence 6.0 or later with Synchrony (required for collaborative editing), you'll need to use Apache 2.4.10 or later, and also check that the mod_proxy_wstunnel and mod_rewrite modules are enabled.

Expand to see Windows instructions

Windows refers to Apache as 'httpd', with the configuration file stored in the location \conf\httpd.conf.

Enable mod_proxy and supporting modules in the Apache httpd.conf configuration file by uncommenting (i.e. remove the leading '#') the following lines if necessary:

LoadModule proxy_module modules/mod_proxy.so 
LoadModule proxy_connect_module modules/mod_proxy_connect.so 
LoadModule proxy_http_module modules/mod_proxy_http.so

If these lines don't exist in the configuration file, just add them.

If you're using Confluence 6.0 or later with Synchrony (required for collaborative editing), you'll need to use Apache 2.4.10 or later, and also enable the mod_proxy_wstunnel and mod_rewrite modules.

2. Configure virtual hosts using mod_proxy

If you are running a single Atlassian application behind an Apache reverse proxy, use a virtual host block with the following directives:

<VirtualHost *:80>
    ServerName <subdomain>.<domain>.com
     
    ProxyRequests Off
    ProxyVia Off
     
    <Proxy *>
         Require all granted
    </Proxy>
 
    ProxyPass /<contextpath> http://<internal_domain>:<port>/<contextpath>
    ProxyPassReverse /<contextpath> http://<internal_domain>:<port>/<contextpath>
</VirtualHost>
  • Note that for CentOS, the preferred approach is to add the virtual host block to a separate configuration file for each application in /etc/httpd/conf.d/, for example named confluence-vhost.conf and jira-vhost.conf.
  • Note that for Debian, the preferred approach is to add the virtual host block to a separate configuration file for each application in  /etc/apache2/sites-available/<site>, for example named  confluence.conf and/or jira.conf. These should be based on the default template, 000-default.conf.

 

If you have multiple applications running behind the same proxy, you can use name-based virtual hosts:

  • Use a single name-based virtual host if the Atlassian applications are under the same domain but have different context paths. For example:

    <VirtualHost *:80>
        ServerName mycompany.com
         
        ProxyRequests Off
        ProxyVia Off
         
        <Proxy *>
             Require all granted
        </Proxy>
     
        ProxyPass /jira http://<internal_domain>:8080/jira
        ProxyPassReverse /jira http://<internal_domain>:8080/jira
     
        ProxyPass /bitbucket http://<internal_domain>:7990/bitbucket
        ProxyPassReverse /bitbucket http://<internal_domain>:7990/bitbucket
    </VirtualHost>
  • Use multiple name-based virtual hosts if each application is on a different domain. For example:

    <VirtualHost *:80>
        ServerName myjira.com
         
        ProxyRequests Off
        ProxyVia Off
         
        <Proxy *>
             Require all granted
        </Proxy>
     
        ProxyPass /jira http://<internal_domain>:8080/jira
        ProxyPassReverse /jira http://<internal_domain>:8080/jira
    </VirtualHost>
     
    <VirtualHost *:80>
        ServerName mybitbucket.com
         
        ProxyRequests Off
        ProxyVia Off
         
        <Proxy *>
             Require all granted
        </Proxy>
     
        ProxyPass /bitbucket http://<internal_domain>:7990/bitbucket
        ProxyPassReverse /bitbucket http://<internal_domain>:7990/bitbucket
    </VirtualHost>


If you're using Confluence 6.0 or later with Synchrony (which is required for collaborative editing),  you'll need to use Apache 2.4.10 or later...

... and these directives and location blocks (click to expand)

Use the following directives and location blocks in the virtual host block:

(warning) Use the directives/locations in the exact order listed below. Do not change the order.

<VirtualHost *:80>
    ServerName myconfluence.com
 
	ProxyRequests Off
	
	# Auth changes in 2.4 - see http://httpd.apache.org/docs/2.4/upgrading.html#run-time
	<Proxy *>
		Require all granted
	</Proxy>

	ProxyPass /synchrony http://<internal_domain>:8091/synchrony

	<Location /synchrony>
		Require all granted
		RewriteEngine on
		RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
		RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
		RewriteRule .* ws://<internal_domain>:8091%{REQUEST_URI} [P]
	</Location>

	ProxyPass / http://<internal_domain>:8090/
	ProxyPassReverse / http://<internal_domain>:8090/

	<Location />
		Require all granted
	</Location>
 
</VirtualHost>

This is a basic example, where Confluence is accessed without a context path and does not use Confluence's internal proxy. See Administering Collaborative Editing for other proxy configuration options.

 

For more information about virtual hosts see https://httpd.apache.org/docs/2.4/vhosts/.

 

The directives inside the virtual host block perform these functions:

Directive Function
<VirtualHost *:80>
Configure directives for a particular virtual host

Use the character * as a wildcard to match all IP addresses, with the default port of 80. This causes Apache to match requests on the ServerName values of the virtual hosts.

See the Apache 2.4 VirtualHost documentation.

ServerName <subdomain>.<domain>.com
Identify the server

The ServerName directive can be used to set the request scheme, hostname and port that the server uses to identify itself.

Examples:

  • www.example.com
  • jira.example.com

The ServerName directive should not include the context path. If

See the Apache 2.4 ServerName documentation.

ProxyRequests Off
Turn off forward proxying

This directive tells Apache to turn off forward proxying. You only need to include this directive if you are using Apache HTTP Server as just a reverse proxy, and not as a forward proxy server.

See the Apache 2.4 ProxyRequests documentation.

ProxyVia Off
Control headers in the proxied request

The ProxyVia directive controls the use of the  Via: HTTP header by the proxy, to control the flow of proxy requests along a chain of proxy servers. Set ProxyVia to Off, to prevent another global configuration from overriding this.

See the Apache 2.4 ProxyVia documentation.

<Proxy *>
 Require all granted
</Proxy>
Allow proxying to the Atlassian application from everywhere

Strictly speaking, this step is unnecessary because access to proxied resources is unrestricted by default. Nevertheless, we explicitly allow access to the Atlassian application from any host so that this policy will be applied regardless of any subsequent changes to access controls at the global level. The Proxy directive provides a context for the directives that are contained within its delimiting tags. In this case, we specify a wild-card URL (the asterisk), which applies the contained directive to all proxied requests.

See the Apache 2.4 Proxy directive documentation.

Note that for Apache 2.2, you need to use the following instead:

<Proxy *>
    Order Deny,Allow
    Allow from all
</Proxy>

The Order directive controls the order in which any Allow and Deny directives are applied. In the above configuration, we specify "Deny,Allow", which tells Apache HTTP Server to apply any Deny directives first, and if any match, the request is denied unless it also matches an Allow directive. In fact, "Deny,Allow" is the default; we include it merely for the sake of clarity. Note that we specify one Allow directive, which is described below, and don't specify any Deny directives. The Allow directive, in this context, controls which hosts can access the Atlassian application via Apache HTTP Server. Here, we specify that all hosts are allowed access.

See the Apache 2.2 Proxy directive documentation.

ProxyPass /<contextpath> http://<domain>:<port>/<contextpath>
ProxyPassReverse /<contextpath> http://<domain>:<port>/<contextpath>

These directives tell Apache HTTP Server to forward requests of the form  http://example.com/*  to port 8080 on the same machine, which is the port we configured Tomcat to listen on above.

The example below shows how to use the context path ( /<contextpath> described above with mod_ajp. If you're not using a context path, you can omit <contextpath> from your ProxyPass and ProxyPassReverse directives by appending a '/' after the domain name or port:

ProxyPass        /<contextpath> http://example:8080/<contextpath>
ProxyPassReverse /<contextpath> http://example:8080/<contextpath>

The example below shows how to access the application at the private.example.com subdomain, with the context path /<contextpath>, and connecting to Tomcat on port 9900:

ProxyPass        /<contextpath> http://private.example.com:9900/<contextpath>
ProxyPassReverse /<contextpath> http://private.example.com:9900/<contextpath>

Note that you could use localhost instead of <domain> if you are running the Atlassian application on the same machine as Apache.

Don't use a trailing '/' after a context path.

See the Apache 2.4  ProxyPass  and  ProxyPassReverse  directives documentation.

 

3. Restart Apache

Debian and Ubuntu

Restart Apache from the command line using:

$ sudo service apache2 restart

Fedora and CentOS

Restart Apache from the command line using:

$ sudo apachectl graceful

You can also use systemd to restart Apache. On CentOS, for example, use:

$ sudo systemctl restart httpd.service

Windows

You can stop and start the Apache service by going to Control Panel > Administrative Tools > Services , look for "Apache2" and select it. Now, on the menu bar select the stop button (square) and wait for the status of the service to change to 'Stopped'. Once the service has stopped select the start button (triangle) and wait for the status to change to 'Started'.

 

4. Modify the CentOS SELinux policy

For CentOS, the SELinux policy blocks httpd from connecting with the network by default. In this case you'll see a "permission denied" message in the httpd error_log similar to this:

[Sat Mar 19 00:29:45.722758 2016] [proxy:error] [pid 5958] (13)Permission denied: AH00957: HTTP: attempt to connect to 127.0.0.1:8090 (localhost) failed

You need to manually modify the SELinux policy for the httpd process using the following command:

$ sudo /usr/sbin/setsebool -P httpd_can_network_connect 1

5. Enable the X-Forwarded-For header

This is an optional step that ensures the origin IP (ie the user connecting to the proxy) is sent to the Atlassian application rather than the proxy IP. This is useful for trying to track down who is submitting requests, as otherwise the reverse-proxy can mask their IP. If this change is done, access logs will record the IP of the client, and also the proxy, rather than just the proxy. To do so:

  1. Enable the mod_remoteip module.
  2. Add the below to the appropriate virtual host:

    RemoteIPHeader X-Forwarded-For
  3. Restart / Reload Apache.

Part C. Final configuration

Restart each application

Now, restart each application and ensure you can access them using new URLs. See the stopping and starting instructions above.

Set the application Base URL

For each Atlassian application, set the Base URL to the address you configured in the proxy, which is the URL that Apache HTTP Server will be serving (such as  http://www.example.com/<atlassianapp > ).

 

 

Disable HTTP compression

Running compression on both the proxy and Tomcat can cause problems when integrating one Atlassian application with another. We recommend disabling HTTP compression for JIRA applications and Confluence:

Last modified on Sep 21, 2017

Was this helpful?

Yes
No
Provide feedback about this article

Not finding the help you need?

Ask the community

Powered by Confluence and Scroll Viewport.