• 搜索: ???
?
?
Tomcat中HTTP与AJP差别与整合 - Tomcat

时间:2018-09-27

配置:httpd.conf

?# Virtual hosts

?#这个#去掉,使其启动;

?Include conf/httpd-vhosts.conf

?

#使用ajp做代理

?LoadModule proxy_module modules/mod_proxy.so

?LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

?#若使用http代理,还需要以下

?LoadModule proxy_connect_module modules/mod_proxy_connect.so

?LoadModule proxy_http_module modules/mod_proxy_http.so

?LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

?LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

?
?配置:httpd-vhosts.conf


?#以下是使用ajp_proxy,这里的8009端口需要与tomcat的ajp端口一致



??? DocumentRoot "/tomcat/webapps/ROOT"
??? ServerAdmin adm@mail.com
??? ServerName? mocai.com
??? ProxyPass / ajp://localhost:8009/ retry=6
??? ProxyPassReverse / ajp://localhost:8009/?
??? DirectoryIndex index.html index.jsp index.htm index.php
???????
??????????????? Options Includes ExecCGI FollowSymLinks
??????????????? AllowOverride All
??????????????? Order allow,deny
??????????????? Allow from all
???????

?#以下是http_proxy负载均衡

?
??ServerName localhost
??#负载均衡
??ProxyPass / balancer://test/
??
??BalancerMember http://a.mocai.com:8080/
???BalancerMember http://b.mocai.com:8090/
??

?


?
??ServerName localhost
??ProxyPass / http://127.0.0.1:8080/
??ProxyPassReverse / http://127.0.0.1:8080/
?

?

3、tomcat:

?配置:server.xml

?

?

?

?
?????????????? connectionTimeout="20000"
?????????????? redirectPort="8443" />

--------------------------------------------------------------------------------------------------------------------------------
经测试,http_proxy 应该是透明重定向代理,它会将输入的域名重定到代理的地址并显示出来,
而ajp_proxy是通过Connector连接器组件与客户程序建立连接,Connector组件负责接收客户的请求,以及把Tomcat服务器的响应结果发送给客户

1

?