1. 程式人生 > >tomcat的配置文件server.conf中的元素的理解

tomcat的配置文件server.conf中的元素的理解

turn tran tco catalina blog 組合 info 容器 follow

tomcat的配置文件server.conf中的元素的理解


tomcat作為一個servlet服務器本身的配置文件是tomcat_home/conf/server.conf,這個配置文件中有很多元素,這些元素各是什麽意思,需要搞清楚,這裏記錄一下目前清楚的幾個元素的含義。

tomcat本身是由一系列可配置的組件組成的,配置文件中的每一個元素都代表一個tomcat的組件。

1、Server元素

=============

Server元素代表servlet容器本身。

A Server element represents the entire Catalina servlet container.Therefore, 
it must be the single outermost element in the conf/server.xml
configuration file.
Its attributes represent the characteristics of the servlet container as a whole.

2、Service

==========

Service元素代表了connector和engine的組合。

A Service element represents the combination of one or more Connector components
that share a single Engine component for processing incoming requests. One or more Service elements may be nested inside a Server element.

  

3、Engine元素

===============

Engine元素代表了一個Service組件的整個請求處理機構。

The Engine element represents the entire request processing machinery associated with a particular Catalina Service. 
It receives and processes all requests from one or more Connectors,
and returns the completed response to the Connector for ultimate transmission back to the client. Exactly one Engine element MUST be nested inside a Service element,
following all of the corresponding Connector elements associated with this Service.

  

4、service中的兩種connector

========================

在service元素中有兩個connector元素,這兩個connector元素的protocol屬性的值是不一樣的,一個是HTTP/1.1,另一個是AJP/1.3。

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>

它們兩者的區別如下:

Tomcat中HTTP與AJP的區別:
Tomcat服務器通過Connector連接器組件與客戶程序建立連接,Connector組件負責接收客戶的請求,以及把Tomcat服務器的響應結果發送給客戶。默認情況下,Tomcat在server.xml中配置了兩種連接器:

第一個連接器監聽8080端口,負責建立HTTP連接。在通過瀏覽器訪問Tomcat服務器的Web應用時,使用的就是這個連接器。

第二個連接器監聽8009端口,負責和其他的HTTP服務器建立連接。在把Tomcat與其他HTTP服務器集成時,就需要用到這個連接器。

5、未完待續

===============

。。。

參考資料:

1、tomcat 9 docs的configuration頁面,https://tomcat.apache.org/tomcat-9.0-doc/config/service.html

2、Tomcat: Connector中HTTP與AJP差別與整合,https://www.cnblogs.com/itcomputer/p/4873823.html

tomcat的配置文件server.conf中的元素的理解