【问题标题】:Fronting two tomcat Servers with Apache HTTP server使用 Apache HTTP 服务器前置两个 tomcat 服务器
【发布时间】:2014-07-28 03:47:52
【问题描述】:

我试图在同一个域下托管两个不同的上下文(在 2 个不同的 tomcat 服务器上)。上下文是相关的,应该托管在相同的域名下。 比如说http://test.com/test1http://test.com/test2

apache http 服务器已经使用以下配置将互联网流量路由到http://test.com/test1

<VirtualHost *:80 *:443>
   ServerName test.com
   ProxyRequests Off
<Proxy balancer://test1Bal>
   BalancerMember ajp://tomcat1_host:8009/tomcat1
</Proxy>
    ProxyPass /test1/ balancer://test1Bal/
    ProxyPass / balancer://test1Bal/    
</VirtualHost> 

如果我点击 URL http://test.com/test2,有什么方法可以让 apache http 服务器为来自 tomcat2 服务器的页面/请求提供服务?

非常感谢!

【问题讨论】:

    标签: apache mod-rewrite tomcat7 url-redirection


    【解决方案1】:

    只有一个节点,您可以移除平衡器。您也不需要重定向 /ProxyPass 行。

    使用以下配置。

    <VirtualHost *:80 *:443>
       ServerName test.com
       ProxyRequests Off
       ProxyPass /test1/ ajp://tomcat1_host:8009/tomcat1
       ProxyPass /test2/ ajp://tomcat2_host:8009/tomcat2
    </VirtualHost> 
    

    【讨论】:

    • 谢谢!效果很好,只是我必须在 test1 和 test2 之后删除 / ! ProxyPass /test1 ajp://tomcat1_host:8009/tomcat1 ProxyPass /test2 ajp://tomcat2_host:8009/tomcat2
    猜你喜欢
    • 2017-04-19
    • 2010-11-10
    • 1970-01-01
    • 1970-01-01
    • 2014-11-09
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 2015-07-29
    相关资源
    最近更新 更多