1、Apache与Jetty的联通

Apache:通过在httpd.conf文件中

 
  
  1. <IfModule mod_proxy.c> 
  2.     ProxyRequests Off 
  3.     ProxyPreserveHost On 
  4.     ProxyErrorOverride On 
  5.  
  6.     <Directory proxy:*> 
  7.         Order deny,allow 
  8.         Allow from all 
  9.     </Directory> 
  10.            
  11.     ProxyPass /r http://localhost:7001/r  
  12.            
  13.     ProxyPass /a http://localhost:7001/ 
  14.          
  15.     SetEnv force-proxy-request-1.0 1 
  16.     SetEnv proxy-nokeepalive 1  
  17.  
  18. </IfModule>  

解释:通过ProxyPass将/r转换为http://localhost:7001/r,将/a转换为ttp://localhost:7001/ ,即:将/r、/a访问的内容交给7001的jetty容器来处理。

 在Jetty的配置文件(例如:simpleanti-jetty.xml)中,

 
  
  1. <Call name="addConnector"> 
  2.       <Arg> 
  3.           <New class="org.eclipse.jetty.server.nio.SelectChannelConnector"> 
  4.  
  5.             <Set name="host"><Property name="jetty.host" default="localhost"></Property></Set> 
  6.             <Set name="port"><Property name="jetty.port" default="7001"/></Set> 
  7.             <Set name="maxIdleTime">20000</Set> 
  8.             <Set name="Acceptors">2</Set> 
  9.             <Set name="acceptQueueSize">256</Set> 
  10.             <Set name="statsOn">false</Set> 
  11.             <Set name="confidentialPort">8443</Set> 
  12.             <Set name="lowResourcesConnections">250</Set> 
  13.             <Set name="lowResourcesMaxIdleTime">5000</Set> 
  14.           </New> 
  15.       </Arg> 
  16.     </Call> 

解释:通过<Set name="host"><Property name="jetty.host" default="localhost"></Property></Set> 

接管apache传递过来的页面请求,再进行处理。

总结:Apache和Jetty之间通过mod_proxy.c进行通信的。