Apache+mod_jk+Tomcat (4)-----the three together

As can be seen from the previous three articles, each part can work normally, so how to connect the three of them is the content of this article. Before doing it, let's take a look at the overall function of mod_jk.

 

The overall function of the mod_jk module is
because the HTTP processing part of tomcat is written by Java (native library appeared after version 5.5.12 to improve its I/O and SSL performance [1]), load in the case of high concurrency higher. And apache's processing ability for static files is stronger than tomcat, so the tomcat development team developed the mod_jk module used in combination with apache. This protocol is used as a request proxy by apache, which converts the request of the HTTP protocol into an AJP protocol package and transmits it to the backend tomcat. (ajp worker)
mod_jk and apache now commonly use the AJP1.3 protocol [2]. It is a binary format protocol that parses faster than the character format HTTP protocol.

 

In addition to the performance improvement, there are also the following functions:
1. Another function of mod_jk can realize the one-to-many correspondence between apache and tomcat, so that the back-end tomcat load balances. (lb worker)
2.mod_jk also provides monitoring of the link between apache and tomcat. (status worker)

 

The typical workflow of the mod_jk module is as follows:
an HTTP request comes, and the mod_jk module selects an appropriate worker to process according to its URI. If it is lb_worker (worker for load balancing), then select the appropriate ajp_worker (worker that handles AJP protocol) in the background according to various conditions. ajp_worker assembles HTTP protocol packets into AJP protocol format packets, and then selects an idle link and sends it to the background tomcat server. When the data is sent from the background, it receives and parses the AJP protocol, reassembles it into the HTTP protocol, and then sends the result to the client.

 

The three together

1. Like the status worker with mod_jk, configuring ajp worker also involves two configuration files:
1)./etc/httpd/conf.d/mod_jk.conf
append -->JKMount /* tomcat1

2)./etc/httpd/conf/workers.properities
worker.list=tomcat1,jkstatus

# Define status worker
#
worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8009

worker.jkstatus.type=status

 

2. Restart apache
systemctl restart httpd

 

3. Visit the URL
http://192.168.100.29/test/index.jsp

 

Conclusion, successfully accessed tomcat's data through apache (80)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326323934&siteId=291194637