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.so LoadModule proxy_balancer_module /usr/ali/apache2/modules/mod_proxy_balancer.so LoadModule proxy_http_module /usr/ali/apache2/modules/mod_proxy_http.so LoadModule proxy_ajp_module /usr/ali/apache2/modules/mod_proxy_ajp.so LoadModule jk_module /usr/ali/apache2/modules/mod_jk.so
然后在httpd.conf末尾加上反向代理配置
ProxyRequests Off <Proxy *> Order deny,allow Allow 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,allow Allow from all </Proxy> ProxyPass /test balancer://mycluster ProxyPass / balancer://mycluster <Proxy balancer://mycluster> BalancerMember http://localhost:8080 BalancerMember http://localhost:8090 </Proxy>
相关推荐
87901735 2019-05-29
lizhengfa 2019-05-17
smallwhale 2011-07-13
HatsuneMiku 2011-06-19
stoneechogx 2019-10-23
quguang 2019-10-23
sarsgetaway 2015-03-18
linuxprobe0 2017-09-23
星月高悬 2011-12-16
积跬步以至千里 2016-07-11
TyCoding 2016-04-08
onlylixiaobei 2015-01-04
CSDNMrWang 2011-05-19
tracyn 2014-04-28
TyCoding 2012-05-19
hwhanwan 2010-06-24
码路心路知行合一 2011-11-18