First, the experimental explanation
Apache HTTP Serverand theTomcat Serverintegration, is generally hoped for the user only to publishApache HTTP Serverthe URL, whileTomcatThe URL is not published, playing a role behind the hero. AccessTomcatof theHTTPrequest, byApacheforwarded toTomcat,Tomcatwhen you are finished processing,HTTPresponse returned toApache, and thenApache HTTPThe response is sent back to the client browser.
apache HTTP server and Tomcat server direct HTTP There are many ways to transfer data.
method one mod_jk Apache HTTP server and Tomcat server integration is all about the mod_jk.so mod_jk apache and Tomcat
Method Two , URL rewrite , that is, for the specified format. URL , forwarded to a Tomcat 's web site. The specified format, referred to here, refers to the regular expression used by Apache , which, in layman's terms, is a more advanced wildcard similar to * . This method does not need to be under the additional files, only need to configure Apache.
Method Three,MOD_PROXY_AJP, only inApache 2.1and later versions,Apachea new feature module that comes with it. At thisApacheUseApache Jserv Protocolwith theTomcatcommunication. Does not need to be under the additional files that need to be changedApacheand theTomcatThe default profile is required to be changed.
method Four , Mod_proxy . In fact mod_proxy can do similar to Wingate the same company LAN share Internet proxy, can also do reverse proxy (Reverse proxy) . The reverse proxy function is used here, and the client browser does not need to change the proxy server to the Apache address here. mod_proxy is an Apache feature, and the configuration is relatively simple.
Second, the experimental environment
Below I choose Method Four , the configuration simplicity is not complex:
I am using two servers to do the following environment:
Red Hat 6.2 bit IP Address 192.168.2.10 and 192.168.2.12
Apache deployed on 10 servers, Tomcat deployed on two servers
Third, the experimental steps
Yum install–y gcc httpd
[ port forwarding configuration ]
through Http_proxy do Tomcat Port Forwarding:
Description: Mapping a remote server to a local server URL Space
Syntax: Proxypass [ path ]!| URL [ key = value key = value ...]] [Nocanon]
Context: Server config, virtual host, directory
Status: Extended
module: Mod_proxy
Configuration httpd.conf :
# ensure that the following modules are loaded
Loadmoduleproxy_module modules/mod_proxy.so
Loadmoduleproxy_http_module modules/mod_proxy_http.so
LoadModule Rewrite_module modules/mod_rewrite.so
LoadModule Proxy_connect_module modules/mod_proxy_connect.so
LoadModule Proxy_balancer_module modules/mod_proxy_balancer.so
# Configuration Proxypass
vi/etc/httpd/conf/httpd.conf <virtualhost *:80> ServerAdmin [email protected] ServerName 192.168.2.10 Prox Ypreservehost on Proxypass/one http://192.168.2.10:8080/one proxypassreverse/one http://192.168.2.10:8080/one P Roxypreservehost on Proxypass/two http://192.168.2.12:8082/two proxypassreverse/two http://192.168.2.12:8082/two< ;/virtualhost>
Service httpd Resload
This article is from "Operation and maintenance record Mei Ling" blog, please be sure to keep this source http://meiling.blog.51cto.com/6220221/1559458
Linux under Apache reverse proxy tomcat