首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

apache反向署理到jetty

2012-07-04 
apache反向代理到jettyapache和jetty组合使用有三种方式There are three main ways to connect Apache to

apache反向代理到jetty

apache和jetty组合使用有三种方式

There are three main ways to connect Apache to Jetty:   1. Using Apache mod_proxy and a normal Jetty HTTP connector.   2. Using Apache mod_proxy_ajp and the Jetty AJP connector.   3. Using Apache mod_jk and the Jetty AJP connector. 

?

jetty推荐的是第一种

We recommend using the HTTP connectors for the following reasons:    * Jetty performs significantly better with HTTP.    * The AJP protocol is poorly documented and has many version irregularities.If you must use AJP, the mod_proxy_ajp module is better than mod_jk. Previously, the load balancing capabilities of mod_jk meant that you had to use (tolerate) it, but with Apache 2.2, mod_proxy_balancer is available and works over HTTP and AJP connectors. 

?

第一种用mod_proxy,实际上是配置反向代理,只是简单的将url转发到jetty,如果要实现负载均衡,apache还需要加载mod_blancer。具体配置比较简单,首先在httpd.conf添加module

LoadModule proxy_module /usr/ali/apache2/modules/mod_proxy.soLoadModule proxy_balancer_module /usr/ali/apache2/modules/mod_proxy_balancer.soLoadModule proxy_http_module /usr/ali/apache2/modules/mod_proxy_http.soLoadModule proxy_ajp_module /usr/ali/apache2/modules/mod_proxy_ajp.soLoadModule jk_module /usr/ali/apache2/modules/mod_jk.so

?

然后在httpd.conf末尾加上反向代理配置

ProxyRequests Off<Proxy *>Order deny,allowAllow from all</Proxy>ProxyPass /test http://localhost:8080/ProxyPass / http://localhost:8080/

?

apache配置的是80端口,当访问http://localhost或者http://localhost/test时,请求应该转发到jetty,就是http://localhost:8080,配置完成后,启动apache,然后访问http://localhost,访问的是jetty页面。


如果要配置负载均衡,假设本机有两个jetty实例,监听端口分别是8080,8090。则简单的负载均衡配置部分如下

ProxyRequests Off<Proxy *>Order deny,allowAllow from all</Proxy>ProxyPass /test balancer://myclusterProxyPass / balancer://mycluster<Proxy balancer://mycluster>BalancerMember http://localhost:8080BalancerMember http://localhost:8090</Proxy> 
?


热点排行