How do I setup Artifactory to run as the “ROOT” application in Tomcat?

Following each of the methods has to be done while Artifactory is not running.

Prerequisites

Starting Artifactory 5.9, in case of an HA cluster, the following should be added to each node's $ARTIFACTORY_HOME/etc/ha-node.properties:
access.context.url=http://<HOST_IP>:<PORT>/access
For example, this is how the ha-node.properties should look like:
node.id=art1
context.url=http://10.0.0.121:8081/artifactory
access.context.url=http://10.0.0.121:8081/access
membership.port=10001
primary=true

Method #1 – Renaming the artifactory.war

1. Rename the $ARTIFACTORY_HOME/webapps/artifactory.war to "ROOT.war"
2. Rename $ARTIFACTORY_HOME/tomcat/conf/Catalina/localhost/artifactory.xml to "ROOT.xml"
3. Edit the “ROOT.xml” file, change the context path to "/" and docBase to "${artifactory.home}/webapps/ROOT.war"
4. Remove the $ARTIFACTORY_HOME/tomcat/work/Catalina/ directory if this exists
5. Remove the $ARTIFACTORY_HOME/tomcat/webapps/ROOT/ and $ARTIFACTORY_HOME/tomcat/webapps/artifactory/ directories if those exist

 

When upgrading, the above steps have to be performed following the upgrade.
 

Method #2 – Editing the server.xml

1. Remove the $ARTIFACTORY_HOME/tomcat/conf/Catalina/localhost/artifactory.xml
2. Remove the $ARTIFACTORY_HOME/tomcat/webapps/ROOT/ and $ARTIFACTORY_HOME/tomcat/webapps/artifactory/ directories if those exist
3. Edit the $ARTIFACTORY_HOME/tomcat/conf/server.xml file as follows:
 
For Artifactory versions below 5.4:
<Server port="8015" shutdown="SHUTDOWN">
   <Service name="Catalina">
       <Connector port="8081"/>
       <Engine name="Catalina" defaultHost="localhost">
           <Host name="localhost" appBase="webapps">
             <Context path="" docBase="${artifactory.home}/webapps/artifactory.war" processTlds="false">
               <Manager pathname="" />
              </Context>
           </Host>
       </Engine>
   </Service>
</Server>

 

For Artifactory versions 5.4 and above
<Server port="8015" shutdown="SHUTDOWN">
   <Service name="Catalina">
       <Connector port="8081"/>
       <Engine name="Catalina" defaultHost="localhost">
           <Host name="localhost" appBase="webapps" startStopThreads="2">
             <Context path="" docBase="${artifactory.home}/webapps/artifactory.war" processTlds="false">
              <Manager pathname="" />
             </Context>
           </Host>
       </Engine>
   </Service>
</Server>

 

For Artifactory versions 5.7 and above
<Server port="8015" shutdown="SHUTDOWN">
   <Service name="Catalina">
       <Connector port="8081" sendReasonPhrase="true"/>

       <Connector port="8040" sendReasonPhrase="true" maxThreads="50"/>
       <Engine name="Catalina" defaultHost="localhost">
           <Host name="localhost" appBase="webapps" startStopThreads="2">
             <Context path="" crossContext="true" docBase="${artifactory.home}/webapps/artifactory.war" processTlds="false">
              <Manager pathname="" />
             </Context>
           </Host>
       </Engine>
   </Service>
</Server>

 
sendReasonPhrase="true" – was added in 5.6.1 to allow accommodation for Artifactory's Tomcat version update and interaction between the YUM client and YUM repositories.
** crossContext="true" – This is very important to ensure the possibility to reach the Access server via the Artifactory port.

When Upgrading:
1. Backup the server.xml and restore it to the new “tomcat” directory as mentioned in the upgrade instructions.
2. Remove the $ARTIFACTORY_HOME/tomcat/conf/Catalina/localhost/artifactory.xml.
3. Remove the $ARTIFACTORY_HOME/tomcat/webapps/ROOT/ and $ARTIFACTORY_HOME/tomcat/webapps/artifactory/ directories if those exist