apache+tomcat整合(二)
前面我介绍了apache+tomcat的mod_jk的整合方式,这里我介绍http_proxy的整合方式,系统环境和上篇的一样,只是重新编译了apache
重新编译apache,是为了让apache的配置文件中自动加载一些模块,编译方式:
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-rewrite=shared --enable-proxy --enable-proxy=shared --enable-speling --enable-speling=shared --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
查配置文件:
#进行上述的编译之后,httpd.conf配置文件会自动加载这些模块,其中mod_proxy_http.so是我们需要的模块
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_scgi_module modules/mod_proxy_scgi.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule speling_module modules/mod_speling.so LoadModule rewrite_module modules/mod_rewrite.so
修改httpd.conf文件,添加如下配置
ProxyPass /bbs http://localhost:8088/bbs
ProxyPassReverse /bbs http://localhost:8088/bbs ##
tomcat server.xml配置文件:
<Connector port="8088" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
在webapps下创建bbs目录
[root@ORACLE bbs]# pwd /usr/local/tomcat6.0/webapps/ROOT/bbs
访问:
127.0.0.1 - - [07/Apr/2015:13:57:25 +0800] "GET /bbs/time.jsp HTTP/1.1" 200 43 127.0.0.1 - - [07/Apr/2015:13:58:06 +0800] "GET /bbs/time.jsp HTTP/1.1" 200 43 127.0.0.1 - - [07/Apr/2015:13:59:30 +0800] "GET /bbs HTTP/1.1" 302 - 127.0.0.1 - - [07/Apr/2015:13:59:30 +0800] "GET /bbs/ HTTP/1.1" 200 130 127.0.0.1 - - [07/Apr/2015:13:59:41 +0800] "GET /bbs/ HTTP/1.1" 200 130 127.0.0.1 - - [07/Apr/2015:14:01:40 +0800] "GET /bbs/index.jsp HTTP/1.1" 200 174 127.0.0.1 - - [07/Apr/2015:14:01:40 +0800] "GET /bbs/index.jsp HTTP/1.1" 200 174 127.0.0.1 - - [07/Apr/2015:14:24:08 +0800] "GET /bbs/time.jsp HTTP/1.1" 200 43
可以看到访问成功!!!