2014-09-29 54 views

回答

4

你可以通過使用mod_jk或mod_proxy指導基於應用程序的請求的apache web服務器來實現此目的。 (並獲得兩個擴展的解釋)

要選擇要使用的Apache項目的擴展:apache to tomcat: mod_jk vs mod_proxy

+0

這就是要走的路! – 2014-09-29 07:40:20

1

它不可能運行兩個服務通過單端口服務。每個端口號只能運行一個tomcat。

1

一次只能有一個進程在某個端口監聽。所以你想要做的並不是直接可能的。將請求轉發到其他實例或將另一臺服務器用作前端(例如Apache)可能會有好運。

2

是的,你可以。在server.xml中替換:

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> 
    <!-- SingleSignOn valve, share authentication between web applications 
     Documentation at: /docs/config/valve.html --> 
    <!-- 
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
    --> 
    <!-- Access log processes all example. 
     Documentation at: /docs/config/valve.html 
     Note: The pattern used is equivalent to using pattern="common" --> 
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
      prefix="localhost_access_log." suffix=".txt" 
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 
</Host> 

通過

<Host name="app1.com" appBase="webappsApp1" unpackWARs="true" autoDeploy="true"> 

    <!-- SingleSignOn valve, share authentication between web applications 
     Documentation at: /docs/config/valve.html --> 
    <!-- 
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
    --> 

    <!-- Access log processes all example. 
     Documentation at: /docs/config/valve.html 
     Note: The pattern used is equivalent to using pattern="common" --> 
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
      prefix="localhost_access_log." suffix=".txt" 
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 
</Host> 

<Host name="app2.com" appBase="webappsApp2" unpackWARs="true" autoDeploy="true"> 

    <!-- SingleSignOn valve, share authentication between web applications 
     Documentation at: /docs/config/valve.html --> 
    <!-- 
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
    --> 

    <!-- Access log processes all example. 
     Documentation at: /docs/config/valve.html 
     Note: The pattern used is equivalent to using pattern="common" --> 
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
      prefix="localhost_access_log." suffix=".txt" 
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 
</Host> 

在你把應用1,同爲webappsApp2目錄和App2的戰爭webappsApp1目錄。

在App1和App2的dns區域放置服務器的公共IP地址。

0

是的,你可以在同一個端口上運行多個tomcat實例(或任何其他對象)。 爲此,您需要將多個真實IP綁定到VIP,然後每個RIP可以使用他們自己的一組端口進行收聽。

因此,每個tomcat將運行在相同的端口上,但在不同的真實IP地址上運行。

0

不同實例與不同的上下文中有相同的端口號:

<!-- Test1 --> 
    <Host name="192.168.1.254" appBase="webapps" 
     unpackWARs="true" autoDeploy="true"> 

    <!-- SingleSignOn valve, share authentication between web applications 
     Documentation at: /docs/config/valve.html --> 
    <!-- 
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
    --> 

    <!-- Access log processes all example. 
     Documentation at: /docs/config/valve.html 
     Note: The pattern used is equivalent to using pattern="common" --> 
    <Context docBase="Testing" path="/" reloadable="true"/> 
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
      prefix="254_access_log" suffix=".txt" 
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 

    </Host> 

    <!-- Test2 --> 
    <Host name="192.168.1.250" appBase="webapps1" 
     unpackWARs="true" autoDeploy="true"> 

    <!-- SingleSignOn valve, share authentication between web applications 
     Documentation at: /docs/config/valve.html --> 
    <!-- 
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
    --> 

    <!-- Access log processes all example. 
     Documentation at: /docs/config/valve.html 
     Note: The pattern used is equivalent to using pattern="common" --> 
    <Context docBase="Testing2" path="/" reloadable="true"/> 
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
      prefix="250_access_log" suffix=".txt" 
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 

    </Host> 

    <!-- Test3 --> 

    <Host name="192.168.1.249" appBase="webapps2" 
     unpackWARs="true" autoDeploy="true"> 

    <!-- SingleSignOn valve, share authentication between web applications 
     Documentation at: /docs/config/valve.html --> 
    <!-- 
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> 
    --> 

    <!-- Access log processes all example. 
     Documentation at: /docs/config/valve.html 
     Note: The pattern used is equivalent to using pattern="common" --> 
    <Context docBase="Testing3" path="/" reloadable="true"/> 
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
      prefix="249_access_log" suffix=".txt" 
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> 

    </Host> 
相關問題