새소식

반응형
IT/Developer-etc

[tomcat] 톰켓 포트 번호 두개 지정하는 방법

  • -
반응형

2022-09-13


Photo by Keith Tanner on Unsplash


- 방법

 

톰켓이 설치된 디렉터리에 /conf/server.xml을 열어보면 tomcat 실행 시에 적용되는 서버 설정이 있다. 그중에서 service 태그에 적혀 있는 내용이 현재 프로젝트 포트 및 경로가 적혀 있는 부분이다.

 

  <Service name="Catalina">

    <Connector port="8080" protocol="HTTP/1.1"
    maxHttpHeaderSize="8192" keepAliveTimeout="500"
    enableLookups="false" disableUploadTimeout="true" acceptCount="10"
               maxThreads="700" minSpareThreads="50" maxSpareThreads="50"
               connectionTimeout="20000"
               URIEncoding="UTF-8"/>

    <Connector port="8180" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <Context path="" docBase="/home/" privileged="true" workDir="/home/" />

      </Host>
    </Engine>
    </Service>

바로 밑에 이를 복사하여 똑같이 하나 더 만들어주고 service name 과 connector port 만 중복되지 않게 설정해 주면 하나의 톰캣 서버에서 두 개의 포트를 http로 리슨 할 수 있게 된다.

 

  <Service name="Catalina">

    <Connector port="8080" protocol="HTTP/1.1"
    maxHttpHeaderSize="8192" keepAliveTimeout="500"
    enableLookups="false" disableUploadTimeout="true" acceptCount="10"
               maxThreads="700" minSpareThreads="50" maxSpareThreads="50"
               connectionTimeout="20000"
               URIEncoding="UTF-8"/>

    <Connector port="8180" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <Context path="" docBase="/home/" privileged="true" workDir="/home/" />

      </Host>
    </Engine>
    </Service>
    
<Service name="Catalina1">

    <Connector port="8081" protocol="HTTP/1.1"
    maxHttpHeaderSize="8192" keepAliveTimeout="500"
    enableLookups="false" disableUploadTimeout="true" acceptCount="10"
               maxThreads="700" minSpareThreads="50" maxSpareThreads="50"
               connectionTimeout="20000"
               URIEncoding="UTF-8"/>

    <Connector port="8180" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8"/>

    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <Context path="" docBase="/home/" privileged="true" workDir="/home/" />

      </Host>
    </Engine>
    </Service>

메인 이미지 출처 : Photo by Keith Tanner on Unsplash  

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.