Create a script to run Tomcat. At the start of the script, export JAVA_OPTS to specify a value for the Tomcat port.http.nonssl (note that you can call this property no matter what you want).
export JAVA_OPTS=-Dport.http.nonssl=${CATALINA_BASE_PORT}
As you can see, I set port.http.nonssl to the environment variable ${CATALINA_BASE_PORT}
Then the script starts Tomcat:
$CATALINA_HOME/bin/startup.sh
Now you need to modify the Tomcat $CATALINA_HOME/conf/server.xml file so that the non-SSL HTTP connector uses the port.http.nonssl property instead of the hardcoded value.
<Connector port="${port.http.nonssl}" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" />
Now Tomcat will use the port defined in the environment variable $ {CATALINA_BASE_PORT} whenever you start it with a new start script.
source share