Apache Reverse proxy back-end Tomcat

Source: Internet
Author: User

In a variety of enterprise Web application Systems, JSP is also a more use of a web development language, for such a site server, must be able to support the Java environment, JSP parsing, such as the installation of Tomcat, JBoss and other JSP containers. On the other hand, Apache HTTP Server is more capable of processing static HTML pages, so if you can integrate the JSP containers such as Apache and Tomcat, you will get a better experience with the Web service.

In this case, Apache still accesses the front-end service as a browser, and when the client requests access to the *.JSP Web page, it automatically invokes the back-end Tomcat service for parsing and returns the resulting page to the client. The communication process requires the installation of the connector MOD_JK to complete.


Back-end installation Tomcat:

Install the JDK development environment [[Email protected] ~]# cd /setup/[[email protected] setup]# chmod  +x jdk-6u20-linux-i586.bin [[email protected] setup]# ./ Jdk-6u20-linux-i586.bin Decompression tomcat[[email protected] setup]# vim /var/www/html/index.jsp  tar zxf apache-tomcat-7.0.23.tar.gz -c /usr/local/tomcat[[email protected]  ~]# ln -s /usr/local/tomcat/bin/startup.sh /usr/local/sbin/tomcat-up[[email  protected] ~]# ln -s /usr/local/tomcat/bin/shudown.sh  /usr/local/sbin/ Tomcat-down Add environment variable vim /etc/profile:java_home=/setup/jdk1.6.0_20catalina_home=/usr/local/tomcatclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $CATALINA _home/lib/servlet-api.jarpath= $JAVA _home/bin:$ Pathexport java_home classpath path  catalina_home Test jdk:[[email protected]  setup]# java -versionjava version  "1.6.0_20"Java (tm)  SE Runtime Environment  (BUILD&NBSP;1.6.0_20-B02) Java hotspot (tm)  client  VM  (build 16.3-b01, mixed mode, sharing) modify Tomcat's server.xml configuration file:[[email  Protected] setup]# vim /usr/local/tomcat/conf/server.xml  <engine name= " Catalina " defaulthost=" www.w4ya.com " jvmroute=" jvm1 ">   #把默认主机改为" www.w4ya.com "     



Installing Apache on front-end servers

[[email protected] http]# tar xf apr-1.5.1.tar.gz [[email protected]  http]# cd apr-1.5.1[[email protected] apr-1.5.1]# ./configure --prefix=/usr/ Local/apr[[email protected] apr-1.5.1]# make && make install[[email  protected] http]# tar xf apr-util-1.5.4.tar.gz [[email protected]  Http]# cd apr-util-1.5.4[[email protected] apr-util-1.5.4]# ./configure --prefix =/usr/local/apr-util --with-apr=/usr/local/apr[[email protected] apr-util-1.5.4]# make  && make installwith-apr=/usr/local/apr[[email protected] setup]# tar  jxf pcre-8.35.tar.bz2 [[email protected] setup]# cd pcre-8.35[[email  protected] pcre-8.35]# ./configure[[email protected] pcre-8.35]# make &&  make install[[email protected] httpd-2.4.10]# ./configure --prefix=/usr/local/apache --enable-so -- enable-ssl  --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/ usr/local/apr  --with-apr-util=/usr/local/apr-util/ --enable-mpms-shared=all  -- with-mpm=event  --enable-proxy --enable-proxy-http --enable-proxy-ajp  -- Enable-proxy-balancer  --enable-lbmethod-heartbeat --enable-hearbeat --enable-slotmem-shm  --enable-slotmem-plain --enable-watchdog[[email protected] httpd-2.4.10]# make  && make install[[email protected] conf]# vim /usr/local/apache/conf/ httpd.conf loadmodule slotmem_shm_module modules/mod_slotmem_shm.so   //Open this module


The first method of Apache directly proxies Tomcat:

[[email protected] conf]# vim/usr/local/apache/conf/httpd.conf//Introduction configuration file include/usr/local/apache/conf/ Http-proxy.conf[[email protected] conf]# vim http-proxy.conf//Add the following in the configuration file <virtualhost *:80>proxyvia Onproxyrequests Offproxypreservehost onproxypass/http://192.168.1.115:8080proxypassreverse/http:// 192.168.1.115:8080<proxy *> Require all granted</proxy><location/> Require all Granted</location ></VirtualHost>


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/54/98/wKiom1SHCpPhwR36AAEFjbjgw64735.jpg "title=" Tomcat1.png "alt=" Wkiom1shcpphwr36aaefjbjgw64735.jpg "/>



The second method uses the MOD_JK proxy:

[[email protected] setup]# weget http://mirrors.cnnic.cn/apache/tomcat/tomcat-connectors/ jk/tomcat-connectors-1.2.40-src.tar.gz[[email protected] setup]# tar xf  tomcat-connectors-1.2.40-src.tar.gz [[email protected] setup]# cd  tomcat-connectors-1.2.40-src/native/[[email protected] native]# ./configure --with-apxs=/ Usr/local/apache/bin/apxs[[email protected] native] #make  &&  make  install[[email protected] modules]# ls /usr/local/apache/modules/ |grep  "Mod_ Jk.so "mod_jk.so[[email protected] conf]# vim /usr/local/apache/conf/httpd.conf // Add the following: loadmodule  jk_module  modules/mod_jk.sojkworkersfile  /usr/local/apache/ conf/workers.propertiesjklogfile  logs/mod_jk.logjkloglevel  debugjkshmfile logs/ Jk.shmjkmount  /*  tomcatjkmount  /status/  stat[[email protected] conf]# vim workers.properties// Container configuration file Worker.list=tomcat,stat1worker. Tomcat.port=8009worker. Tomcat.host=192.168.1.116worker. Tomcat.type=ajp13worker. Tomcat.lbfactor=1worker.stat.type = status Restart Apache


Apache Agent to TOMCATB:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/54/96/wKioL1SHDOLixMs9AAD6shgkM5g887.jpg "title=" 1.png " alt= "Wkiol1shdolixms9aad6shgkm5g887.jpg"/>


This article turns from: Visia Comprehensive forum : http://www.w4ya.com/forum.php

This article from "Dragon Love Xue Qi" blog, reproduced please contact the author!

Apache Reverse proxy back-end Tomcat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.