简体   繁体   English

使用Apache HTTP服务器前置两个tomcat服务器

[英]Fronting two tomcat Servers with Apache HTTP server

I am trying to host the two different context (on 2 different tomcat servers) under the same domain. 我正在尝试在同一域下托管两个不同的上下文(在2个不同的tomcat服务器上)。 The contexts are related and should be hosted under same domain name. 上下文是相关的,并且应使用相同的域名托管。 Lets say http://test.com/test1 and http://test.com/test2 . 假设http://test.com/test1http://test.com/test2

The apache http server already routing the internet traffic to http://test.com/test1 using the below configuration. apache http服务器已经使用以下配置将Internet通信路由到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> 

Is there any way if i hit the URL http://test.com/test2 , the apache http server should serve the pages/requests from the tomcat2 server ? 如果我点击URL http://test.com/test2 ,有什么方法可以使apache http服务器提供来自tomcat2服务器的页面/请求?

Thank you very much! 非常感谢你!

With a only a single node, you can remove the balancer. 仅使用一个节点,就可以删除平衡器。 You also don't need the ProxyPass line that is redirecting / . 您也不需要重定向/ProxyPass行。

Use the following configuration. 使用以下配置。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM