<?xml version="1.0" encoding="utf-8"?>
<!--
   ====================================================================================

   Atlassian Bamboo Data Center Tomcat Configuration.


   See the following for more information

   https://confluence.atlassian.com/display/BAMBOO/Installing+and+upgrading+Bamboo

   ====================================================================================
 -->
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<Server port="8007" shutdown="SHUTDOWN">

    <!--APR library loader. Documentation at /docs/apr.html -->
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on"/>
    <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

    <!-- Global JNDI resources
         Documentation at /docs/jndi-resources-howto.html
    -->

    <!-- A "Service" is a collection of one or more "Connectors" that share
        a single "Container" Note:  A "Service" is not itself a "Container",
        so you may not define subcomponents such as "Valves" at this level.
        Documentation at /docs/config/service.html
    -->
    <Service name="Catalina">

        <Connector
                port="${bamboo.catalina.connector.port}"
                protocol="HTTP/1.1"

                maxThreads="150" minSpareThreads="25"
                connectionTimeout="20000"
                disableUploadTimeout="true"
                acceptCount="100"

                enableLookups="false"
                maxHttpHeaderSize="8192"

                useBodyEncodingForURI="true"
                URIEncoding="UTF-8"

                scheme="${bamboo.catalina.connector.scheme}" secure="${bamboo.catalina.connector.secure}"
                proxyName="${bamboo.catalina.connector.proxyname}" proxyPort="${bamboo.catalina.connector.proxyport}"

                redirectPort="8443">
            <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        </Connector>

        <!--
        ====================================================================================
        To run Bamboo DC behind a load balancer configured with HTTPS you will
        need to:
            * Include the proxy configurations without the certificate options
            * Include the load balancer url
            * Make sure the Base URL of Bamboo is using the load balancer url

        Remember that it will be the load balancer that will contain all the
        HTTPS configuration, not the Bamboo DC nodes.
        ====================================================================================
        -->
        <!--
            <Connector
                port="8085"
                protocol="HTTP/1.1"

                maxThreads="150" minSpareThreads="25"
                connectionTimeout="20000"
                disableUploadTimeout="true"
                acceptCount="100"

                enableLookups="false"
                maxHttpHeaderSize="8192"

                useBodyEncodingForURI="true"
                URIEncoding="UTF-8"

                proxyName="<INSERT THE LOAD BALANCER URL>"
                proxyPort="443"
                scheme="https"

                redirectPort="8443">
            <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        </Connector>
        -->

        <!--
        ====================================================================================
        To run Bamboo via HTTPS:
             * Uncomment the Connector below
             * Execute:
                 %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
                 $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)
               with a password value of "changeit" for both the certificate and the keystore itself.
             * Restart and visit https://localhost:8443/

             For more info, see :
              https://confluence.atlassian.com/display/BAMBOO/Securing+Bamboo+with+Tomcat+using+SSL
              and
              http://tomcat.apache.org/tomcat-8.5-doc/ssl-howto.html
        ====================================================================================
        -->
        <!--
        <Connector
            port="8443"

            maxThreads="150" minSpareThreads="25"
            connectionTimeout="20000"
            disableUploadTimeout="true"
            acceptCount="100"

            enableLookups="false"
            maxHttpHeaderSize="8192"

            useBodyEncodingForURI="true"
            URIEncoding="UTF-8"

            scheme="https" secure="true" SSLEnabled="true" sslProtocol="TLS"
            clientAuth="false" />
         -->
        <!--
         ====================================================================================

         If you have Apache AJP Connector (mod_ajp) as a proxy in front of Bamboo you should uncomment the following connector configuration line

         See the following for more information :

            https://confluence.atlassian.com/display/BAMBOO/Securing+Bamboo+with+Apache+using+SSL

         ====================================================================================
        -->

        <!--
              <Connector port="8009" redirectPort="8443" enableLookups="false" protocol="AJP/1.3" URIEncoding="UTF-8"/>
        -->

        <Engine name="Catalina" defaultHost="localhost">
            <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

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

                    <!--<Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"-->
                              <!--factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>-->
                    <Manager pathname=""/>
                </Context>

            </Host>

            <Valve className="org.apache.catalina.valves.AccessLogValve" requestAttributesEnabled="true"
                   pattern="&quot;%{X-Forwarded-For}i&quot; %a %t &quot;%m %U%q %H&quot; %s %b %D &quot;%{Referer}i&quot; &quot;%{User-Agent}i&quot;"/>

            <!-- StuckThreadDetectionValve added below to print stack traces if a thread has been stuck for 60 seconds -->
            <Valve className="org.apache.catalina.valves.StuckThreadDetectionValve" threshold="60" />
        </Engine>
    </Service>
</Server>
