2012-01-10 71 views
3

我有兩個WAR文件在我的tomcat 6服務器上運行。Tomcat一個端口只有一個WAR

如何設置每個WAR只偵聽一個端口? 例如:

端口443 =>僅可以訪問a.war

端口8000 =>只能b.war

回答

3

我管理使用這些設置來配置上述場景訪問:我創建了兩個文件夾名爲和根據webapp文件夾,並配置兩個Service-elements指向兩個不同的文件夾並偵聽兩個不同的端口。

server.xml中

<Service name="Catalina"> 
<Connector port="8000" protocol="HTTP/1.1" SSLEnabled="true" 
      maxThreads="150" scheme="https" secure="true" 
      keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx" 
      clientAuth="false" sslProtocol="TLS" /> 

<Engine name="Catalina" defaultHost="localhost"> 
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
     resourceName="UserDatabase"/> 

    <Host name="localhost" appBase="webapps/8000" 
     unpackWARs="true" autoDeploy="true" 
     xmlValidation="false" xmlNamespaceAware="false"> 
      <Context path="" docBase="Apple"/> 
    </Host> 
</Engine></Service> 

<Service name="Catalina2"> 
<Connector port="8080" protocol="HTTP/1.1" 
      connectionTimeout="20000" 
      redirectPort="443" /> 

<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" 
      maxThreads="150" scheme="https" secure="true" 
      keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx" 
      clientAuth="false" sslProtocol="TLS" /> 

<Engine name="Catalina2" defaultHost="localhost"> 
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
     resourceName="UserDatabase"/> 

    <Host name="localhost" appBase="webapps/443" 
     unpackWARs="true" autoDeploy="true" 
     xmlValidation="false" xmlNamespaceAware="false"> 
    </Host> 
</Engine></Service> 
相關問題