How do I setup Artifactory to run as the “ROOT” application in Tomcat?
Disclaimer: JFrog's recommended approach to remove the "/artifactory" context is to achieve this by a Load-balancer or a Reverse-Proxy.
Manually editing the Tomcat path is discouraged, and will not be supported in future releases of Artifactory.
The purpose of this article is to provide general guidance to users who yet decide to achieve this by Tomcat modifications.
Subject
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=https://<HOST_IP>:<PORT>/access
For example, this is how the ha-node.properties should look like:node.id=art1
context.url=https://10.0.0.121:8081/
access.context.url=https://10.0.0.121:8081/access
membership.port=10001
primary=true
For Artifactory 6.0 and above, the following System Property should be added in $ARTIFACTORY_HOME/etc/artifactory.system.properties
:artifactory.context.path=/
Instructions
Method #1 – Renaming the artifactory.war
$ARTIFACTORY_HOME/webapps/artifactory.war
to "ROOT.war
"$ARTIFACTORY_HOME/tomcat/conf/Catalina/localhost/artifactory.xml
to "ROOT.xml
"ROOT.xml
” file, change the context path to "/
" and docBase to "${artifactory.home}/webapps/ROOT.war
"$ARTIFACTORY_HOME/tomcat/work/Catalina/
directory if this exists$ARTIFACTORY_HOME/tomcat/webapps/ROOT/
and $ARTIFACTORY_HOME/tomcat/webapps/artifactory/
directories if those exist
Method #2 – Editing the server.xml
$ARTIFACTORY_HOME/tomcat/conf/Catalina/localhost/artifactory.xml
$ARTIFACTORY_HOME/tomcat/webapps/ROOT/
and $ARTIFACTORY_HOME/tomcat/webapps/artifactory/
directories if those exist$ARTIFACTORY_HOME/tomcat/conf/server.xml
file as follows:<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>
<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>
<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>
<Server port="8015" shutdown="SHUTDOWN">
<Service name="Catalina">
<Connector port="8081" sendReasonPhrase="true" relaxedPathChars='[]' relaxedQueryChars='[]'/>
<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.
server.xml
and restore it to the new “tomcat” directory as mentioned in the upgrade instructions.$ARTIFACTORY_HOME/tomcat/conf/Catalina/localhost/artifactory.xml
.$ARTIFACTORY_HOME/tomcat/webapps/ROOT/
and $ARTIFACTORY_HOME/tomcat/webapps/artifactory/
directories if those existץ