use ProxyPass to connect apache and tomcat

when we want to proxy apache request to tomcat, we can use ProxyPass. First we should build apache like this:

./configure \
    --prefix=/opt/apache22 \
    --enable-so \
    --enable-mods-shared=all \
    --with-included-apr \
    --enable-proxy=shared \
    --enable-cache=shared \
    --enable-file-cache=shared \
    --enable-disk-cache=shared \
    --enable-mem-cache=shared


    make
    make install

 

then we can config /conf/httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

ProxyPass /resources !    //disable redirect
ProxyPass / ajp://127.0.0.1:3873/           //direct to tomcat with ajp protocol
ProxyPassReverse / ajp://127.0.0.1:3873/

 

It's very easy to use ProxyPass! But if we want to make more complex rule, e..g,

use other static resources on the apache, we should use mod_jk.

 

你可能感兴趣的:(apache,tomcat,cache)