Tomcat The architecture of the figure

Tomcat Organizational structure of

Tomcat It's a component-based server , Its components are configurable , The outermost of them is Catalina servlet Containers , Other components are configured in the top-level container according to certain format requirements . 
Tomcat The various components of are in Tomcat Install under directory /conf/server.xml Configured in the file .

from Server.xml Look at the structure of Tomcat Architecture of

1
2
3
4
5
6
7
8
9
10
11
12
< Server >                                                // Top level class elements , Can include multiple Service   
     < Service >                                           // Top level class elements , Can contain a Engine, Multiple Connecter
         < Connector >                                     // Connector class elements , On behalf of the communication interface
                 < Engine >                                // Container class elements , For the specific Service Component handles customer requests , To include more than one Host
                         < Host >                          // Container class elements , Handle client requests for specific virtual host components , Can contain more than one Context
                                 < Context >               // Container class elements , For the specific Web App handles all customer requests
                                 </ Context >
                         </ Host >
                 </ Engine >
         </ Connector >
     </ Service >
</ Server >

Configuration file details

1. Tomcat Configuration file for

Tomcat By default, the configuration file of is stored in /usr/local/tomcat/conf Directory , There are mainly the following

    

server.xml: Tomcat Primary profile for , contain Service, Connector, Engine, Realm, Valve, Hosts Configuration information of the main component ;
web.xml: follow Servlet Specification standard configuration file , Used for configuration servlet, And for all Web Application offers include MIME Default configuration information such as mapping ;
tomcat-user.xml:Realm Related roles used in authentication 、 User and password information ;Tomcat Self contained manager This file is used by default ; stay Tomcat Add / Delete user , Assigning roles to users will be achieved by editing this file ;
catalina.policy:Java Related security policy configuration file , The ability to provide access control at the system resource level ;
catalina.properties:Tomcat Inside package The definition and access control of , It also includes control over what is loaded through the class loader ;Tomcat6 The relevant settings of this file will be read in advance at startup ;
logging.properties: Tomcat6 Through its own internal realization JAVA Loggers are used to record operation related logs , This file is the configuration information related to the logger , It can be used to define the component level of logging and the location of log files ;
context.xml: all host Default configuration information ;

2. Server.xml

Tomcat Run in an object-oriented way , It can dynamically load the object structure defined in the configuration file at run time , It's kind of like apache Of httpd How to call a module .server.xml Each primary element defined in is created as an object , And organize these objects together in a specific hierarchy . Here is a sample configuration :

<Server port=”8005″ shutdown=”SHUTDOWN”>
<Listener className=”org.apache.catalina.core.JasperListener” />
<Listener className=”org.apache.catalina.mbeans.ServerLifecycleListener” />
<Listener className=”org.apache.catalina.mbeans.GlobalResourcesLifecycleListener” /> <GlobalNamingResources>
<Resource name=”UserDatabase” auth=”Container”
type=”org.apache.catalina.UserDatabase”
description=”User database that can be updated and saved”
factory=”org.apache.catalina.users.MemoryUserDatabaseFactory”
pathname=”conf/tomcat-users.xml”/>
</GlobalNamingResources> <Service name=”Catalina”> <Connector port=”8080″ protocol=”HTTP/1.1″
maxThreads=”150″ connectionTimeout=”20000″
redirectPort=”8443″/> <Engine name=”Catalina” defaultHost=”localhost”> <Host name=”localhost” appBase=”webapps”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>
</Host>
</Engine>
</Service>
</Server> <Server port=”8005″ shutdown=”SHUTDOWN”>
<Listener className=”org.apache.catalina.core.AprLifecycleListener” SSLEngine=”on” />
<Listener className=”org.apache.catalina.core.JasperListener” />
<Listener className=”org.apache.catalina.core.JreMemoryLeakPreventionListener” />
<Listener className=”org.apache.catalina.mbeans.GlobalResourcesLifecycleListener” />
<Listener className=”org.apache.catalina.core.ThreadLocalLeakPreventionListener” /> <GlobalNamingResources>
<Resource name=”UserDatabase” auth=”Container”
type=”org.apache.catalina.UserDatabase”
description=”User database that can be updated and saved”
factory=”org.apache.catalina.users.MemoryUserDatabaseFactory”
pathname=”conf/tomcat-users.xml” />
</GlobalNamingResources> <Service name=”Catalina”> <Connector port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″ />
<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ /> <Engine name=”Catalina” defaultHost=”localhost”> <Realm className=”org.apache.catalina.realm.LockOutRealm”>
<Realm className=”org.apache.catalina.realm.UserDatabaseRealm”
resourceName=”UserDatabase”/>
</Realm> <Host name=”localhost” appBase=”webapps”
unpackWARs=”true” autoDeploy=”true”> <Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”localhost_access_log.” suffix=”.txt”
pattern=”%h %l %u %t &quot;%r&quot; %s %b” /> </Host>
</Engine>
</Service>
</Server> 

server.xml There are so many elements that can be defined in the file , Include Server, Service, Connector, Engine, Cluster, Host, Alias, Context, Realm, Valve, Manager, Listener, Resources, Resource, ResourceEnvRef, ResourceLink, WatchedResource, GlobalNameingResources, Store, Transaction, Channel, Membership, Transport, Member, ClusterListener etc. .

Details of common components

1.  top floor Server Components

It will make Tomcat6 Start a server example ( That is, a JVM), It's listening in 8005 Port to receive shutdown command , Use telnet Connect 8005 Ports can be executed directly SHUTDOWN Command to close Tomcat. various Server The definition of cannot use the same port , This means that if more than one is started on the same physical machine Server example , They have to be configured to use different ports . The definition of this port is used to provide a convenient way for the administrator to close this instance , therefore , Administrators can directly telnet This port uses SHUTDOWN Command to close this instance . however , From a security perspective , This is usually not allowed remotely .

<Server port="8005" shutdown="SHUTDOWN" debug="0">
1>className: Specify implementation org.apache.catalina.Server The name of the fully qualified class for the interface . The default value is org.apache.catalina.core.StandardServer
2>port: The server is waiting for the shutdown command TCP/IP Port number . Set to -1 To disable closing ports . By default, only local access is allowed , The default is 8005;
3>shutdown: Must pass TCP/IP The connection received a command string with the specified port number , To close Tomcat. The default is SHUTDOWN
4>address: The server is waiting for the shutdown command TCP/IP Address . If no address is specified , Then use localhost. test :
telnet localhost 8005
Input :SHUTDOWN
result : close tomcat

2. top floor Service Components

Service It is mainly used to associate an engine with multiple connectors related to this engine , Each connector receives inbound requests through a specific port and protocol and forwards them to the associated engine for processing . Trapped here ,Service To include an engine 、 One or more connectors .

**<Service name="Catalina"\>**
**<Service name="Apache"\>**
first <Service> Deal with all directly by Tomcat The server received web Customer request .
the second <Service> Deal with all by Apahce From the server Web Customer request .

1>className Specify implementation org.apahce.catalina.Service The class of the interface . The default is org.apahce.catalina.core.StandardService
2>name: Define the name of this service , This name will also be recorded in the log file when relevant log information is generated . The name of each service associated with a particular server must be unique .

3. Connector Components

Connector The main function of , Is to receive connection requests , establish Request and Response Object is used to exchange data with the requester ; Then assign threads to let Engine To deal with this request , And put the resulting Request and Response The object is passed to Engine.

Get into Tomcat The request can be based on Tomcat There are two kinds of working modes of :Tomcat As an application server : The request comes from the front end web The server , This may be Apache, IISNginx etc. ;Tomcat As a stand-alone server : The request comes from web browser ;

Tomcat We should consider the working situation and define the required connectors for the corresponding requests in order to correctly receive the requests from the client . An engine can have one or more connectors , To accommodate a variety of requests . Defining connectors can use a variety of properties , Some properties only apply to a specific connector type . As a general rule ,

Common in server.xml The connector types in are usually 4 Kind of :1) HTTP The connector 2) SSL The connector 3) AJP 1.3 The connector 4) proxy The connector ;

Tomcat Three protocols are supported :HTTP/1.1、HTTP/2.0、AJP

(1) BIO HTTP/1.1 Connector To configure 
A typical configuration is as follows : 
<Connector port=”8080” protocol=”HTTP/1.1” maxThreads=”150” conn ectionTimeout=”20000” redirectPort=”8443” />
Other important properties are as follows :
acceptCount : Accept the connection request The maximum number of connections , The default value is 10
address : binding IP Address , If you don't bind , By default, any IP Address
allowTrace : If it is true, Will allow TRACE HTTP Method
compressibleMimeTypes : each mimeType, Separated by commas , Such as text/html,text/xml
compression : If bandwidth is limited , It can be used GZIP Compress
connectionTimeout : Timeout time , The default is 60000ms (60s)
maxKeepAliveRequest : The default value is 100
maxThreads : request-processing Connector Number of threads for , The default value is 200

If it is SSL To configure , as follows :
<Connector port="8181" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol = "TLS"
address="0.0.0.0"
keystoreFile="E:/java/jonas-full-5.1.0-RC3/conf/keystore.jks"
keystorePass="changeit" />
among ,keystoreFile For certificate location ,keystorePass Password for Certificate (2) NIO HTTP/1.1 Connector To configure <Connector port=”8080” protocol=”org.apache.coyote.http11.Http11NioProtocol” maxThreads=”150” connectionTimeout=”20000” redirectPort=”8443”/>

(3) Native APR Connector To configure
ARP Yes, it is C/C++ Written , For static resources (HTML, Pictures, etc ) optimized . So download the local library tcnative-1.dll And openssl.exe, Put it on %tomcat%\bin Under the table of contents .
Download address is :http://tomcat.heanet.ie/native/1.1.10/binaries/win32/
stay server.xml To configure a Listener, Here's the picture . This configuration tomcat It's made by default .

<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
Configuration and use APR connector
<Connector port=”8080” protocol=”org.apache.coyote.http11.Http11AprProtocol”
maxThreads=”150” connectionTimeout=”20000” redirectPort=”8443”/>
 If the configuration is successful , start-up tomcat, You will see the following information : org.apache.coyote.http11.Http11AprProtocol init 
(4) AJP Connector To configure
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Coyote HTTP/1.1 Connector

In standalone mode ,Tomcat Can configure HTTP and HTTPS The connector , This can make Tomcat It looks more like the whole web Server to handle static request content and delegate Catalina Engine to handle dynamic content .

 className : The Connector The implementation class is org.apache.coyote.tomcat4.CoyoteConnector
<Connector
port="8080" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false"
redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" /> port : At port number 8080 Listening from customers browser Of HTTP1.1 request . If you put 8080 Change to 80, Then just enter http://localhost/ that will do
protocol: Set up Http agreement , The default value is HTTP/1.1, If you use AJP processor , The value must be AJP/1.3.
minSpareThreads: The Connector First create 5 Threads waiting for client requests , Each request is handled by a thread
maxSpareThreads: Set the maximum number of threads on the listening port , This value also determines the maximum number of requests that the server can respond to at the same time . The default value is
acceptCount
: When the maximum number of existing threads has been reached when , Queuing for customer requests . When the number of requests in the queue exceeds when , Later requests return Connection refused error
redirectport : When the customer request is https when , Forward the request to the port 8443 Go to , If the connector does not support SSL, If received SSL request ,Catalina The container will be automatically redirected to the specified port number , Let it handle it .
enableLookups: Set up as true, Support domain name resolution , hold IP Address resolved to hostname ,false return IP Address .WEB Call in application request.getRemoteHost Method execution DNS The query returns the client host name . The default value is true.
connectionTimeout: Define the timeout period for establishing customer connection , In Milliseconds , The default is 60000=60 second , If -1, Indicates that there is no limit to the time for establishing a customer connection
allowTrace: Whether to allow HTTP Of TRACE Method , The default is false
emptySessionPath: If set to true, All paths of the user will be set to /, The default is false.
maxPostSize: Appoint POST The maximum number of mode requests , Not specified. Default is 2097152.
proxyName: If this connector is being used in a proxy configuration , Specify this property , stay request.getServerName() When to return to
scheme: Set the name of the protocol , stay request.getScheme() When to return to ,SSL The connector is set to ”https”, The default is ”http”
secure: stay SSL Connectors can be set to true, The default is false
URIEncoding: Used to decode URL Character encoding of , The default value is not specified ISO-8859-1
useBodyEncodingForURI: It is mainly used for Tomcat4.1.x in , Indicates whether to use in contentType In place of URIEncoding, Used to decode URI Query parameters , The default is false
xpoweredBy: by true when ,Tomcat Use the header suggested by the specification to indicate support for Servlet The specification version of , The default is false
bufferSize: Set the size of the input stream buffer created by the connector , In bytes . By default , The size of the buffer is 2048 byte
compressableMimeType:MIME A list of , Comma separated by default . The default value is text/html,text/xml,text/plain
compression: Specifies whether the data of the response is compressed .off: Indicates compression is prohibited 、on: Indicates that compression is allowed ( The text will be compressed )、force: Indicates compression in all cases , The default value is off
disableUploadTimeOut: allow Servlet Containers , Executing with a longer connection timeout , In order to make Servlet There is a long time to complete its execution , The default value is false
maxHttpHeaderSize:HTTP Maximum number of request and response headers , In bytes , The default value is 4096 byte
maxKeepAliveRequest: Before the server shut down , The maximum number of pipelines sent by the client . The default value is 100
socketBuffer: set up Socket The size of the output buffer ( In bytes ),-1 Indicates that buffering is prohibited , The default value is 9000 byte
toNoDelay: by true when , Can improve performance . The default value is true
threadPriority: set up JVM Request processing thread priority in . The default value is NORMAL-PRIORITY

AJP The connector :

Is used to Apache And Tomcat Integrate together , When Apache When a dynamic content request is received , Send the request to the... Listening on the port number specified in the configuration AJP Connector as .

In shared mode ,Tomcat Playing the role of web Servers such as Apache httpd、Nginx And Microsoft. IIS The supporting role . here web The server acts as the client through Apache Module or through dll Format ISAPI Module to and Tomcat signal communication . When the module determines that a request needs to be passed in Tomcat When dealing with , It will use AJP The agreement came with Tomcat signal communication , The protocol is binary , stay web The server and Tomcat Communication is more efficient than text-based Http The protocol is more efficient .

<!—Define an AJP1.3 Connector on port 8089-->
<Connector port="8080" maxThread="50" minSpareThreads="25" maxSpareThread="75" enableLookups="false" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" />
<Connection port="8009" enableLookups="false" redirectPort="8443" debug="0" protocol="AJP/1.3" /> backlog: When all possible request processing threads are in use , The maximum number of requests queued in the queue . The default is 10, When the queue is full , Any request will be rejected
maxSpareThread: The maximum number of idle threads allowed , The default value is 50
maxThread: Maximum number of concurrent connections supported , The default value is 200
minSpareThreads: Set the number of threads created when the connector is first started , Make sure that at least so many free threads are available , The default value is 4
port: Server socket TCP Port number , The default value is 8089( must )
topNoDelay: by true when , Can improve performance , The default value is true
soTimeout: Timeout value

SSL The connector :

 The following defines a multi-attribute SSL The connector :
debug="0" Do not start debug mode ;
<Connector port="8443" maxThreads="150" minSpareThreads="25" maxSpareThread="75" enableLookups="false"
acceptCount="100" debug="0" scheme="HTTPs" secure="true" clientAuth="false" sslProtocol="TLS"/>
<Connector port="8181" protocol="HTTP/1.1" SSLEnabled="true" 
    maxThreads="150" scheme="https" secure="true" 
    clientAuth="false" sslProtocol = "TLS" 
    address="0.0.0.0" 
    keystoreFile="E:/java/jonas-full-5.1.0-RC3/conf/keystore.jks" 
    keystorePass="changeit" />

among ,keystoreFile For certificate location ,keystorePass Password for Certificate

The following attributes are in the standard Connector(NIO, NIO2 and APR/native) Effective in

acceptCount : When the maximum request connection maxConnections Maximum queue size at full time , Default 100.
 Notice this property and Executor Middle attribute maxQueueSize The difference between .
This refers to the stack size when the request connection is full ,
Executor Of maxQueueSize Refers to the stack size when the processing thread is full
connectionTimeout: Define the timeout period for establishing customer connection , In Milliseconds , The default is 60000=60 second , If -1, Indicates that there is no limit to the time for establishing a customer connection 
executor: Specifies the name of the configured thread pool
keepAliveTimeout:keeAlive Timeout time , The default value is connectionTimeout Configuration values .-1 No overtime
maxConnections: maximum connection , When the connection is full, the maximum number of subsequent connections is acceptCount Of the queue . Yes NIO and NIO2 Connect , The default value is 10000; Yes APR/native, The default value is 8192
maxThreads: Maximum number of concurrent connections supported , If you specify Executor, This property ignores ; Otherwise Connector Maximum internal thread pool created , Default 200
minSpareThreads If you specify Executor, This property ignores ; Otherwise Connector Minimum number of active threads to create a thread pool , Default 10
processorCache: Protocol processor cache Processor Size of object ,-1 Means unrestricted .
When not used servlet3.0 In the case of asynchronous processing :
If configured Executor, Configure to Executor Of maxThreads;
Otherwise, the configuration is Connnector Of maxThreads.
If you use Serlvet3.0 Asynchronous processing , take maxThreads and maxConnections The maximum of

4. Excutor Components

Executor It means that you can be in Tomcat Shared thread pool between components in .

<Service name="xxx">
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="300" minSpareThreads="25"/>
</Service> className: This class must implement org.apache.catalina.Executor Interface . Default org.apache.catalina.core.StandardThreadExecutor
name : Thread pool name . Ask for the only , for Connector Elemental executor Attributes use
namePrefix: Thread name prefix .
maxThreads: Maximum number of active threads . Default 200
minSpareThreads: Minimum number of active threads . Default 25
maxIdleTime: The current active thread is greater than minSpareThreads when , The maximum waiting time for idle threads to shut down . Default 60000ms
maxQueueSize: The size of the request queue when the thread pool is full . Default Integer.MAX_VALUE

5.  Containers Engine Components

Engine The element represents and is associated with a specific Catalina The entire request processing machine associated with the service . It receives and processes all requests from one or more connectors , And return the completed response to the connector , So that it can finally be transmitted back to the client .

<Engine name=”Catalina” defaultHost=”localhost”>
defaultHost: Default hostname , Used to identify the host that will handle requests to host names on this server that are not configured in this profile . The name must match the name attribute of one of the nested host elements .
name: The logical name of this engine , For logs and error messages . When using multiple service elements in the same server , Each engine must be assigned a unique name .

6.  Containers Host Components

Tomcat Support based on FQDN Virtual host of ,, be located Engine The host or virtual host in the container that receives the request and processes it accordingly

Host The element represents a virtual host , It's the network name of a server ( Such as “www.mycompany.com”) And operation Tomcat Server specific association of .

 Virtual host definition example :
<Engine name=”Catalina” defaultHost=”localhost”>
<Host name=”localhost” appBase=”webapps” unpackWARs=”true” autoDeploy=”true” xmlValidation=”false” xmlNamespaceAware=”false”>
<Context path=”” docBase=”ROOT”/>
<Context path=”/bbs” docBase=”/web/bss” reloadable=”true” crossContext=”true”/> #path It's defined in defaultHost after
</Host> <Host name=”mail.magedu.com” appBase=”/web/mail”>
<Context path=”” docBase=”ROOT”/>
</Host>
</Engine> Host alias definition : If a host has two or more host names , Additional names can be defined as aliases , as follows :
<Host name=”www.ttlsa.com” appBase=”webapps” unpackWARs=”true”>
<Alias>feiyu.com</Alias>
</Host> name: name , For log output
appBase: The application basic path corresponding to the virtual host (Host Of webapps Catalog ); It could be an absolute path , or CATALINABASE Relative paths ||xmlBase| Virtual host XML Basic path , There should be Contextxml The configuration file
createDirs When appBase and xmlBase When there is no , Whether to create a directory The default is true
autoDeploy: Is it periodic appBase and xmlBase and deploy web The application and context The descriptor , The default is true
deployIgnore: Ignore deploy Regular
deployOnStartup: Tomcat Whether it starts automatically deploy, The default is true
failCtxIfServletStartFails: Configure to true Under the circumstances , whatever load-on-startup >=0 Of servlet Boot failure , Then it corresponds to Contxt Also failed to start , The default is false
unpackWars: Enable this webapps Is the time right WAR The format of the archive file is expanded first ; The default is true;

7.  Containers Context Components

Context The element represents a Web Applications , It runs on a specific virtual host . Every Web Applications are based on Web Application archiving (WAR) file , Or the corresponding directory containing the corresponding unpacking content , Such as Servlet As stated in the specification .

<!– Tomcat Root Context –>
<Context path=”” docBase=”/web/webapps”/> <!– buzzin webapp –>
<Context path=”/bbs” docBase=”/web/threads/bbs” reloadable=”true”> </Context> <!– chat server –>
<Context path=”/chat” docBase=”/web/chat”/> <!– darian web –>
<Context path=”/darian” docBase=”darian”/> altDDName: web.xml Deployment descriptor path , Default /WEB-INF/web.xml
docBase: Context Of Root route , and Host Of appBase Combination , Determinable web The actual directory of the application
failCtxIfServletStartFails: Same as Host Medium failCtxIfServletStartFails, Only for the present Context It works , The default is false
logEffectiveWebXml: Whether to print the log web.xml Content (web.xml By default web.xml And in application web.xml form ), The default is false
path: web Applied context path, If it's the root path , Is configured as an empty string (""), You have to configure
privileged: Whether to use Tomcat Provided manager servlet
reloadable:/WEB-INF/classes/ and /WEB-INF/lib/ Directory class Whether to reload automatically when the file changes , The default is false
swallowOutput: true Under the circumstances , System.out and System.err The output will be directed to web In the application log , The default is false 

8.  nesting Realm Components

One Realm Represents a security context , It is an authorization to access a given Context The list of users and the list of roles that a user is allowed to switch . therefore ,Realm It's like a database of users and groups .

 Here is a common use UserDatabase Configuration of :
<Realm className=”org.apache.catalina.realm.UserDatabaseRealm” resourceName=”UserDatabase”/> Here is a use JDBC How to obtain the configuration of user authentication information :
<Realm className=”org.apache.catalina.realm.JDBCRealm” debug=”99″
driverName=”org.gjt.mm.mysql.Driver”
connectionURL=”jdbc:mysql://localhost/authority”
connectionName=”test”
connectionPassword=”test”
userTable=”users”
userNameCol=”user_name”
userCredCol=”user_pass”
userRoleTable=”user_roles”
roleNameCol=”role_name” /> classname, It is Realm Many different implementations of , Used to indicate this Realm Storage location of authentication information such as authenticated users and roles .
JAASRealm: be based on Java Authintication and Authorization Service Realize user authentication ;
JDBCRealm: adopt JDBC Access a relational database table to achieve user authentication ;
JNDIRealm: be based on JNDI Using directory service to obtain authentication information ;
MemoryRealm: lookup tomcat-user.xml File to achieve the acquisition of user information ;
UserDatabaseRealm: be based on UserDatabase file ( Usually tomcat-user.xml) Realize user authentication , Its implementation is completely updatable and persistent MemoryRealm, So we can follow the standard MemoryRealm compatible ; It passes through JNDI Realization ;

9.  nesting Valve Components

Valve Similar to filters , It can work on Engine and Host/Context Between 、Host and Context Between and Context and Web Between some resources of the application . More than one can be created in one container Valve, and Valve The order in which they are defined also determines the order in which they take effect .

Tomcat6 There are many different kinds of Valve:
AccessLogValve: Access log Valve
ExtendedAccessValve: Extended function access log Valve
JDBCAccessLogValve: adopt JDBC Send access log information to the database ;
RequestDumperValve: Request dump Valve;
RemoteAddrValve: Access control based on remote address ;
RemoteHostValve: Access control based on remote host name ;
SemaphoreValve: Used to control the Tomcat The number of concurrent accesses on any container on the host ;
JvmRouteBinderValve: Configure multiple Tomcat For Apache adopt mod_proxy or mod_jk As the front end of the cluster architecture , When a node is expected to stop , You can go through it Valve Direct the memory request to the standby node ; Use this Valve, Must make JvmRouteSessionIDBinderListener;
ReplicationValve: Dedicated to Tomcat In the cluster architecture , Can be at a request of session Trigger when information changes session Data is replicated between nodes ;
SingleSignOn: Two or more users will need to be authenticated webapp Connect when authenticating users , That is, one authentication can access all the connected webapp;
ClusterSingleSingOn: Yes SingleSignOn An extension of , Dedicated to Tomcat In the cluster , Need to combine ClusterSingleSignOnListener Work on ;
RemoteHostValve and RemoteAddrValve It can be used to implement host name based and IP Address access control , Control itself can be achieved by allow or deny To define , It's kind of like Apache Access control function ; Below Valve Only local access is allowed /probe: <Context path=”/probe” docBase=”probe”>
<Valve className=”org.apache.catalina.valves.RemoteAddrValve” allow=”127\.0\.0\.1″/>
</Context> Among them, the relevant attribute definitions are :
1) className: dependent java Class name of the implementation , The corresponding difference should be org.apache.catalina.valves.RemoteHostValve or org.apache.catalina.valves.RemoteAddrValve;
2) allow: Comma separated, accessible IP Address list , regular expression , therefore , Order number “.” be used for IP The address needs to be escaped ; Define only allow Xiang Shi , Ambiguous allow The addresses of are deny;
3) deny: Forbidden by commas IP Address list , regular expression ; Use the same way as allow;

10.  nesting GlobalNamingResources Components

For the entire server JNDI mapping , This can avoid every Web Applications need to be in their own web.xml establish , This is in web Application to WAR It's especially useful when forms exist .

It can usually contain three child elements :Environment,Resource、ResourceEnvRef.

11.  nesting WatchedResource Components

WatchedResource It can be used for Context Monitor the specified webapp Change of procedure documents , And it can reload the file when the content of the file changes .

12.  nesting Listener Components

Listener For creating and configuring LifecycleListener object , and LifecycleListener Usually used by developers to create and delete containers , Monitor life cycle .

13.  nesting Loader Components

Java The dynamic loading function is one of its powerful language functions ,Servlet Containers use this feature to load dynamically at run time servlet And the classes they depend on .Loader It can be used for Context Middle control java Class loading .

14.  nesting Manager Components

Manger Object is used to implement HTTP The function of session management ,Tomcat6 There is 5 Kind of Manger The implementation of the :

1) StandardManager:Tomcat6 The default session manager for , For a single running state in a non clustered environment Tomcat Instance session management . When Tomcat closed , The session related data will be written to a disk named SESSION.ser The file of , And in Tomcat Read this file the next time you start .

2) PersistentManager: When a session is idle for a long time, it will be written to swap Conversation object , This is useful for applications with tight memory resources .

3)DeltaManager: be used for Tomcat The session manager of the cluster , It implements session replication by synchronizing changed session data to other nodes in the cluster . This implementation synchronizes all session changes to every node in the cluster , It is also one of the most widely used implementations in a cluster environment .

4)BackupManager: be used for Tomcat The session manager of the cluster , And DeltaManager The difference is , Changes to a node's session are synchronized only to another node in the cluster, not to all nodes .

5)SimpleTcpReplicationManager:Tomcat4 The version used in , Too old .

15.  nesting Stores Components

PersistentManager Must contain a Store Element to specify where to store session data . There are usually two ways to do this :FileStore and JDBCStore.

16.  nesting Resources Components

Often used to implement in Context Specified in but not in Tomcat Application resources on local disk , Such as Java class ,HTML page ,JSP Documents, etc. .

17.  nesting Cluster Components

Dedicated to configuration Tomcat Elements of the cluster , Can be used for Engine and Host In the container . In use Engine When in a container ,Engine All in Host All support the cluster function . stay Cluster In the elements , You need to define a Manager Elements , This Manager The element has a value of org.apache.catalina.ha.session.DeltaManager or org.apache.catalina.ha.session.BackupManager Of className attribute . meanwhile ,Cluster We also need to define a Channel and ClusterListener Elements .

Channel: be used for Cluster Defines communication for nodes in the same group in the cluster “ channel ”.Channel You need to define at least Membership、Receiver and Sender Three elements , There is also an optional element Interceptor.

Membership: be used for Channel Configuration of the members of the node cluster group on the same communication channel , That is, monitoring the nodes joining the current cluster group and passing heartbeat information among the nodes , And it can be removed from the cluster node when the heartbeat information of a member is not received .Tomcat6 in Membership The implementation of org.apache.catalina.tribes.membership.McastService.

Sender: be used for Channel Middle configuration “ Copy information ” The transmitter of , The implementation sends data that needs to be synchronized to other nodes to other nodes in the cluster . The sender does not need the definition of the property , But you can define a Transport Elements .

Transport: be used for Sender Inside , How to send configuration data to other nodes in the cluster .Tomcat6 There are two kinds of Transport The implementation of the :

1) PooledMultiSender: be based on Java Blocking type IO, Multiple messages can be sent to other nodes at a time , But only one node at a time .

2)PooledParallelSener: be based on Java Non-blocking type IO, namely NIO, Multiple messages can be sent to one or more nodes at a time .

Receiver: be used for Channel Defines how a node from other nodes Sender Receive replication data ,Tomcat6 There are two ways of receiving BioReceiver and NioReceiver.

 

Refer to the website

  1. Tomcat Quick start
  2. Detailed explanation Tomcat The configuration file server.xml
  3. Tomcat in server.xml Configuration details
  4. Tomcat Detailed explanation
  5. tomcat Detailed analysis of components and principles
  6. tomcat framework

Tomcat series (5)——Tomcat More related articles in the configuration details section

  1. Tomcat series (4)——Tomcat Component and architecture details

    The core part of the   1.  Definition Tomcat The server is a free open source Web application server ,Tomcat yes Apache Software foundation (Apache Software Foundation) Of Jakarta ...

  2. Tomcat series (1)——Tomcat Installation configuration

    The core step 1.  install JAVA( because tomcat Depend on java) To configure :JAVA_HOME D:\Program Files (x86)\Java\jdk1.7.0 path  %JAVA_HOME%\ ...

  3. Tomcat series (10)——Tomcat Main design patterns 5 Kind of ( appearance , Responsibility chain , The observer , Template method , Command mode )

    The core part of the Appearance mode : RequestFacade Apply facade mode (facade) To encapsulate HttpServletRequest. Observer mode :  Event monitoring mechanism , Controlling the life cycle of a component Lifecycle .Serv ...

  4. Tomcat series (9)——Tomcat 6 Aspect tuning ( Memory , Threads ,IO, Compress , cache , colony )

    The core part of the Memory Threads IO Compress cache colony One .JVM Memory optimization Tomcat Memory optimization , Including memory size , Garbage collection strategy . Windows Under the catalina.bat,Linux Under the catalina.s ...

  5. Tomcat series (6)——Tomcat Deal with one HTTP Process of request

    Tomcat The architecture of the figure   Figure 3 :Tomcat Server Deal with one HTTP Process of request Handle HTTP Request process Suppose the request from the customer is :http://localhost:8080/test/index.js ...

  6. Tomcat series (3)——Tomcat Components and architecture core 4 Class main components ( top floor , The connector , Containers , nesting )

    1. Architecture diagram 2.  Definition Tomcat The server is a free open source Web application server ,Tomcat yes Apache Software foundation (Apache Software Foundation) Of Jakarta ...

  7. tomcat Log configuration details under

    # Configurable items (5 Class log ):catalina.localhost.manager.admin.host-manager handlers = 1catalina.org.apache.juli.FileH ...

  8. Tomcat series (2)——Tomcat File directory 7 individual

    The core part of the bin ( Run script ) conf ( The configuration file ) lib ( Core library files ) logs ( Log directory ) temp ( Temporary directory ) webapps ( Directory of autoloadable applications ) work (JVM The temporary file ...

  9. Tomcat series (11)——Tomcat Deploy web Applied 4 Methods

    Core content 1. stay Tomcat There are four kinds of deployment in Web The way it's applied , Namely : (1) utilize Tomcat Automatic deployment ( Project direct copy OR WAR Package copy To webapps Next ) (2) Deploy with the console (tomcat Of man ...

Random recommendation

  1. JMeter Study -025-JMeter Command line ( Not GUI) Model details ( 3、 ... and )- Test graphical HTML report form (dashboard) Generate

    Talk less , Pick up Above, continue ... 6. Generate test reports Before generating test reports , You need to complete the performance test results jtl or csv file , Used to generate test results . jmeter -n -t JMeter Distributed test examples .jmx ...

  2. windbg Learning advanced ——windbg Environment variable configuration

    I've always wanted to learn about performance tuning windbg analysis dump, Every time I look at the teacher's orders, I can find the reason for the problem at the bottom, which is simply envy and worship ~ But it's been nearly a year , No progress , The main reason is that this part of the book is stuck ... That's the reason ...

  3. use collectionview Realize waterfall flow - turn

    The general idea of the algorithm Let's talk about the general idea first . Since the size of the picture . Different positions , It's natural for us to think of the need to work out each item Of frame, Then put these frame Assign to current item Of UICollectionViewLayou ...

  4. Spring day02 note

    spring day01 review Writing process ( be based on xml) 1. Import jar package :4+1 --> beans/core/context/expression | commons-logging 2. Compilation items ...

  5. python2 httplib note

    python2  httplib note #coding=utf-8 ''' Created on 2014 year 9 month 25 Japan @author: cocoajin ''' import httplib,url ...

  6. Linking Containers Together

    Linking Containers Together In the Using Docker section we touched on connecting to a service runnin ...

  7. To configure web.xml and glassfish Container implementation javaEE Form validation

    web.xml To configure : <!-- Declare roles for security constraints --> <security-role> <role-name>ReimUser</role-name& ...

  8. Photoshop Example video tutorial

    Photoshop Example video tutorial 2019/04/23 file name size The architectural effect of retro arcade style PS course .mp4 6.63 MB 48.PS The course starts from scratch —— Slice selection tool .mp4 20.90 MB PS course - ...

  9. FTP Connect virtual host response 220 Welcome to www.net.cn FTP service. ( A problem solved )

    Problem scenario : Use FTP When a client connects to a virtual host , The same account and password can be successfully connected under some networks , Some network has been unable to connect :ftp Respond to “220 Welcome to www.net.cn FTP service.” ...

  10. Cache design (cache-design)

    Distributed cache design At present, the common caching schemes are hierarchical caching , It can be divided into the following layers : 1.1NG Local cache , If you hit it, go straight back 1.2 NG When there is no hit, you need to query the distributed cache , Such as redis 1.3 If the distributed cache fails to hit, then ...