2014-09-29 56 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> 
相关问题