LoginSignup
13
18

More than 5 years have passed since last update.

1つのTomcatでROOT.warを複数動かす

Posted at

はじめに

1つのTomcatで複数のROOT.warを動かしたかったのでその時の設定メモ
アプリA、B、Cをそれぞれ8080、8081、8082ポートで動かす

URLのイメージ

server.xml

server.xml
<?xml version='1.0' encoding='utf-8'?>
<Server post="8005" shutdown="SHUTDOWN">

  <!-- アプリAの設定 -->
  <Service name="A">
    <!-- 8080ポートで実行 -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Engine name="A" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <!-- ${TOMCAT_HOME}/webapps_Aディレクトリにwarファイルを配置 -->
      <Host name="localhost" appBase="webapps_A"
            unpackWARs="true" autoDeploy="true">
      </Host>
    </Engine>
  <Service>

  <!-- アプリBの設定 -->
  <Service name="B">
    <!-- 8081ポートで実行 -->
    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8444" />
    <Engine name="B" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <!-- ${TOMCAT_HOME}/webapps_Bディレクトリにwarファイルを配置 -->
      <Host name="localhost" appBase="webapps_B"
            unpackWARs="true" autoDeploy="true">
      </Host>
    </Engine>
  </Service>

  <!-- アプリCの設定 -->
  <Service name="C">
    <!-- 8082ポートで実行 -->
    <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8445" />
    <Engine name="C" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <!-- ${TOMCAT_HOME}/webapps_Cディレクトリにwarファイルを配置 -->
      <Host name="localhost" appBase="webapps_C"
            unpackWARs="true" autoDeploy="true">
      </Host>
    </Engine>
  </Service>

</Server>
13
18
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
18