Proxying Atlassian server applications with Apache HTTP Server (mod_proxy_http)

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.

 


 

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: 

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
  • 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.

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

Use these commands from the Bitbucket installation directory:

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

On Windows, use:

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

See also 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.

Once you've done that, continue with Part B below.

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>

The default locations of server.xml files for Atlassian applications are:

Application server.xml location
JIRA applications <install-path>/conf/server.xml
Confluence <install-path>/conf/server.xml
Bamboo <install-path>/conf/server.xml
Bitbucket Server

Linux: <Bitbucket home directory>/shared/server.xml

Windows: C:\Atlassian\ApplicationData\Bitbucket\shared\server.xml

Note that server.xml is no longer kept in the installation directory, but in the home directory.

Stash 3.8 – 3.11

<Stash home directory>/shared/server.xml

Note that server.xml is no longer kept in the installation directory, but in the home directory.

Stash 3.7 and earlier <install-path>/conf/server.xml
FishEye The FishEye configuration file is config.xml, but see Configuring the FishEye web server.
Crucible As for FishEye.
Crowd

<install-path>/apache-tomcat/conf/server.xml

Note that crowd is predefined as the context path. Updating this requires several steps outlined by Removing the 'crowd' Context from the Application URL.

 

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

 

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 update the Crowd context path.

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'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
  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:

  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.

2. Configure virtual hosts using mod_proxy

Now, add a separate virtual host block in the Apache configuration file for each Atlassian application you want to operate behind the reverse proxy.

  • 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.
<VirtualHost *:80>
    ServerName <subdomain>.<domain>.com
     
    ProxyRequests Off
    ProxyVia Block
    ProxyPreserveHost On
     
    <Proxy *>
         Require all granted
    </Proxy>
 
    ProxyPass /<contextpath> http://<domain>:<port>/<contextpath>
    ProxyPassReverse /<contextpath> http://<domain>:<port>/<atlassianapp>
</VirtualHost>

 

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>).

 

  Click for Base URL instructions...

 

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:

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport