blob: 08423eb9e9544feb9efcdb46a1d09b730a4d3414 [file] [log] [blame]
刘洪青6266f992017-05-15 21:21:03 +08001<html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat 7 Configuration Reference (7.0.77) - The Engine Container</title><meta name="author" content="Craig R. McClanahan"><style type="text/css" media="print">
2 .noPrint {display: none;}
3 td#mainBody {width: 100%;}
4</style><style type="text/css">
5code {background-color:rgb(224,255,255);padding:0 0.1em;}
6code.attributeName, code.propertyName {background-color:transparent;}
7
8
9table {
10 border-collapse: collapse;
11 text-align: left;
12}
13table *:not(table) {
14 /* Prevent border-collapsing for table child elements like <div> */
15 border-collapse: separate;
16}
17
18th {
19 text-align: left;
20}
21
22
23div.codeBox pre code, code.attributeName, code.propertyName, code.noHighlight, .noHighlight code {
24 background-color: transparent;
25}
26div.codeBox {
27 overflow: auto;
28 margin: 1em 0;
29}
30div.codeBox pre {
31 margin: 0;
32 padding: 4px;
33 border: 1px solid #999;
34 border-radius: 5px;
35 background-color: #eff8ff;
36 display: table; /* To prevent <pre>s from taking the complete available width. */
37 /*
38 When it is officially supported, use the following CSS instead of display: table
39 to prevent big <pre>s from exceeding the browser window:
40 max-width: available;
41 width: min-content;
42 */
43}
44
45div.codeBox pre.wrap {
46 white-space: pre-wrap;
47}
48
49
50table.defaultTable tr, table.detail-table tr {
51 border: 1px solid #CCC;
52}
53
54table.defaultTable tr:nth-child(even), table.detail-table tr:nth-child(even) {
55 background-color: #FAFBFF;
56}
57
58table.defaultTable tr:nth-child(odd), table.detail-table tr:nth-child(odd) {
59 background-color: #EEEFFF;
60}
61
62table.defaultTable th, table.detail-table th {
63 background-color: #88b;
64 color: #fff;
65}
66
67table.defaultTable th, table.defaultTable td, table.detail-table th, table.detail-table td {
68 padding: 5px 8px;
69}
70
71
72p.notice {
73 border: 1px solid rgb(255, 0, 0);
74 background-color: rgb(238, 238, 238);
75 color: rgb(0, 51, 102);
76 padding: 0.5em;
77 margin: 1em 2em 1em 1em;
78}
79</style></head><body bgcolor="#ffffff" text="#000000" link="#525D76" alink="#525D76" vlink="#525D76"><table border="0" width="100%" cellspacing="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img src="../images/tomcat.gif" align="right" alt="
Hongqing Liufd5ee812014-05-10 16:32:51 +080080 The Apache Tomcat Servlet/JSP Container
刘洪青6266f992017-05-15 21:21:03 +080081 " border="0"></a></td><td><h1><font face="arial,helvetica,sanserif">Apache Tomcat 7</font></h1><font face="arial,helvetica,sanserif">Version 7.0.77, Mar 28 2017</font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img src="../images/asf-logo.svg" align="right" alt="Apache Logo" border="0" style="width: 266px;height: 83px;"></a></td></tr></table><table border="0" width="100%" cellspacing="4"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><tr><!--LEFT SIDE NAVIGATION--><td width="20%" valign="top" nowrap class="noPrint"><p><strong>Links</strong></p><ul><li><a href="../index.html">Docs Home</a></li><li><a href="index.html">Config Ref. Home</a></li><li><a href="http://wiki.apache.org/tomcat/FAQ">FAQ</a></li><li><a href="#comments_section">User Comments</a></li></ul><p><strong>Top Level Elements</strong></p><ul><li><a href="server.html">Server</a></li><li><a href="service.html">Service</a></li></ul><p><strong>Executors</strong></p><ul><li><a href="executor.html">Executor</a></li></ul><p><strong>Connectors</strong></p><ul><li><a href="http.html">HTTP</a></li><li><a href="ajp.html">AJP</a></li></ul><p><strong>Containers</strong></p><ul><li><a href="context.html">Context</a></li><li><a href="engine.html">Engine</a></li><li><a href="host.html">Host</a></li><li><a href="cluster.html">Cluster</a></li></ul><p><strong>Nested Components</strong></p><ul><li><a href="globalresources.html">Global Resources</a></li><li><a href="jar-scanner.html">JarScanner</a></li><li><a href="listeners.html">Listeners</a></li><li><a href="loader.html">Loader</a></li><li><a href="manager.html">Manager</a></li><li><a href="realm.html">Realm</a></li><li><a href="resources.html">Resources</a></li><li><a href="sessionidgenerator.html">SessionIdGenerator</a></li><li><a href="valve.html">Valve</a></li></ul><p><strong>Cluster Elements</strong></p><ul><li><a href="cluster.html">Cluster</a></li><li><a href="cluster-manager.html">Manager</a></li><li><a href="cluster-channel.html">Channel</a></li><li><a href="cluster-membership.html">Channel/Membership</a></li><li><a href="cluster-sender.html">Channel/Sender</a></li><li><a href="cluster-receiver.html">Channel/Receiver</a></li><li><a href="cluster-interceptor.html">Channel/Interceptor</a></li><li><a href="cluster-valve.html">Valve</a></li><li><a href="cluster-deployer.html">Deployer</a></li><li><a href="cluster-listener.html">ClusterListener</a></li></ul><p><strong>web.xml</strong></p><ul><li><a href="filter.html">Filter</a></li></ul><p><strong>Other</strong></p><ul><li><a href="systemprops.html">System properties</a></li></ul></td><!--RIGHT SIDE MAIN BODY--><td width="80%" valign="top" align="left" id="mainBody"><h1>The Engine Container</h1><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Table of Contents"><!--()--></a><a name="Table_of_Contents"><strong>Table of Contents</strong></a></font></td></tr><tr><td><blockquote>
Hongqing Liufd5ee812014-05-10 16:32:51 +080082<ul><li><a href="#Introduction">Introduction</a></li><li><a href="#Attributes">Attributes</a><ol><li><a href="#Common_Attributes">Common Attributes</a></li><li><a href="#Standard_Implementation">Standard Implementation</a></li></ol></li><li><a href="#Nested_Components">Nested Components</a></li><li><a href="#Special_Features">Special Features</a><ol><li><a href="#Logging">Logging</a></li><li><a href="#Access_Logs">Access Logs</a></li><li><a href="#Lifecycle_Listeners">Lifecycle Listeners</a></li><li><a href="#Request_Filters">Request Filters</a></li></ol></li></ul>
83</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote>
84
85 <p>The <strong>Engine</strong> element represents the entire request
86 processing machinery associated with a particular Catalina
87 <a href="service.html">Service</a>. It receives and processes
88 <em>all</em> requests from one or more <strong>Connectors</strong>,
89 and returns the completed response to the Connector for ultimate
90 transmission back to the client.</p>
91
92 <p>Exactly one <strong>Engine</strong> element MUST be nested inside
93 a <a href="service.html">Service</a> element, following all of the
94 corresponding Connector elements associated with this Service.</p>
95
96</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Attributes"><strong>Attributes</strong></a></font></td></tr><tr><td><blockquote>
97
98 <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Common Attributes"><!--()--></a><a name="Common_Attributes"><strong>Common Attributes</strong></a></font></td></tr><tr><td><blockquote>
99
100 <p>All implementations of <strong>Engine</strong>
101 support the following attributes:</p>
102
刘洪青6266f992017-05-15 21:21:03 +0800103 <table border="1" cellpadding="5"><tr><th width="15%" bgcolor="#023264"><font color="#ffffff">Attribute</font></th><th width="85%" bgcolor="#023264"><font color="#ffffff">Description</font></th></tr><tr><td align="left" valign="center"><code class="attributeName">backgroundProcessorDelay</code></td><td align="left" valign="center">
104 <p>This value represents the delay in seconds between the
105 invocation of the backgroundProcess method on this engine and
106 its child containers, including all hosts and contexts.
107 Child containers will not be invoked if their delay value is not
108 negative (which would mean they are using their own processing
109 thread). Setting this to a positive value will cause
110 a thread to be spawn. After waiting the specified amount of time,
111 the thread will invoke the backgroundProcess method on this engine
Hongqing Liufd5ee812014-05-10 16:32:51 +0800112 and all its child containers. If not specified, the default value for
113 this attribute is 10, which represent a 10 seconds delay.</p>
刘洪青6266f992017-05-15 21:21:03 +0800114 </td></tr><tr><td align="left" valign="center"><code class="attributeName">className</code></td><td align="left" valign="center">
Hongqing Liufd5ee812014-05-10 16:32:51 +0800115 <p>Java class name of the implementation to use. This class must
116 implement the <code>org.apache.catalina.Engine</code> interface.
117 If not specified, the standard value (defined below) will be used.</p>
刘洪青6266f992017-05-15 21:21:03 +0800118 </td></tr><tr><td align="left" valign="center"><strong><code class="attributeName">defaultHost</code></strong></td><td align="left" valign="center">
Hongqing Liufd5ee812014-05-10 16:32:51 +0800119 <p>The default host name, which identifies the
120 <a href="host.html">Host</a> that will process requests directed
121 to host names on this server, but which are not configured in
122 this configuration file. This name MUST match the <code>name</code>
123 attributes of one of the <a href="host.html">Host</a> elements
124 nested immediately inside.</p>
刘洪青6266f992017-05-15 21:21:03 +0800125 </td></tr><tr><td align="left" valign="center"><code class="attributeName">jvmRoute</code></td><td align="left" valign="center">
Hongqing Liufd5ee812014-05-10 16:32:51 +0800126 <p>Identifier which must be used in load balancing scenarios to enable
127 session affinity. The identifier, which must be unique across all
刘洪青6266f992017-05-15 21:21:03 +0800128 Tomcat servers which participate in the cluster, will be appended to
Hongqing Liufd5ee812014-05-10 16:32:51 +0800129 the generated session identifier, therefore allowing the front end
刘洪青6266f992017-05-15 21:21:03 +0800130 proxy to always forward a particular session to the same Tomcat
Hongqing Liufd5ee812014-05-10 16:32:51 +0800131 instance.</p>
刘洪青6266f992017-05-15 21:21:03 +0800132 <p>
133 Note that the <code>jvmRoute</code> can also be set using the
134 <code>jvmRoute</code> system property. The <code>jvmRoute</code>
135 set in an <code>&lt;Engine&gt;</code> attribute will override
136 any <code>jvmRoute</code> system property.
137 </p>
138 </td></tr><tr><td align="left" valign="center"><strong><code class="attributeName">name</code></strong></td><td align="left" valign="center">
Hongqing Liufd5ee812014-05-10 16:32:51 +0800139 <p>Logical name of this Engine, used in log and error messages. <em>When
140 using multiple <a href="service.html">Service</a> elements in the same
141 <a href="server.html">Server</a>, each Engine MUST be assigned a unique
142 name.</em></p>
刘洪青6266f992017-05-15 21:21:03 +0800143 </td></tr><tr><td align="left" valign="center"><code class="attributeName">startStopThreads</code></td><td align="left" valign="center">
144 <p>The number of threads this <strong>Engine</strong> will use to start
145 child <a href="host.html">Host</a> elements in parallel. The special
146 value of 0 will result in the value of
147 <code>Runtime.getRuntime().availableProcessors()</code> being used.
148 Negative values will result in
149 <code>Runtime.getRuntime().availableProcessors() + value</code> being
150 used unless this is less than 1 in which case 1 thread will be used. If
151 not specified, the default value of 1 will be used. </p>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800152 </td></tr></table>
153
154 </blockquote></td></tr></table>
155
156
157 <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Standard Implementation"><!--()--></a><a name="Standard_Implementation"><strong>Standard Implementation</strong></a></font></td></tr><tr><td><blockquote>
158
159 <p>The standard implementation of <strong>Engine</strong> is
160 <strong>org.apache.catalina.core.StandardEngine</strong>.
161 It supports the following additional attributes (in addition to the
162 common attributes listed above):</p>
163
164 <table border="1" cellpadding="5"><tr><th width="15%" bgcolor="#023264"><font color="#ffffff">Attribute</font></th><th width="85%" bgcolor="#023264"><font color="#ffffff">Description</font></th></tr></table>
165
166 </blockquote></td></tr></table>
167
168
169</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Nested Components"><!--()--></a><a name="Nested_Components"><strong>Nested Components</strong></a></font></td></tr><tr><td><blockquote>
170
171 <p>You can nest one or more <a href="host.html">Host</a> elements inside
172 this <strong>Engine</strong> element, each representing a different virtual
173 host associated with this server. At least one <a href="host.html">Host</a>
174 is required, and one of the nested <a href="host.html">Hosts</a> MUST
175 have a name that matches the name specified for the
176 <code>defaultHost</code> attribute, listed above.</p>
177
178 <p>You can nest at most one instance of the following utility components
179 by nesting a corresponding element inside your <strong>Engine</strong>
180 element:</p>
181 <ul>
182 <li><a href="realm.html"><strong>Realm</strong></a> -
183 Configure a realm that will allow its
184 database of users, and their associated roles, to be shared across all
185 <a href="host.html">Hosts</a> and <a href="context.html">Contexts</a>
186 nested inside this Engine, unless overridden by a
187 <a href="realm.html">Realm</a> configuration at a lower level.</li>
188 </ul>
189
190</blockquote></td></tr></table><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Special Features"><!--()--></a><a name="Special_Features"><strong>Special Features</strong></a></font></td></tr><tr><td><blockquote>
191
192
193 <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Logging"><strong>Logging</strong></a></font></td></tr><tr><td><blockquote>
194
刘洪青6266f992017-05-15 21:21:03 +0800195 <p>An engine is associated with the
Hongqing Liufd5ee812014-05-10 16:32:51 +0800196 <code>org.apache.catalina.core.ContainerBase.[enginename]</code>
197 log category. Note that the brackets are actually part of the name,
198 don't omit them.</p>
199
200 </blockquote></td></tr></table>
201
202
203 <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Access Logs"><!--()--></a><a name="Access_Logs"><strong>Access Logs</strong></a></font></td></tr><tr><td><blockquote>
204
205 <p>When you run a web server, one of the output files normally generated
206 is an <em>access log</em>, which generates one line of information for
207 each request processed by the server, in a standard format. Catalina
208 includes an optional <a href="valve.html">Valve</a> implementation that
209 can create access logs in the same standard format created by web servers,
210 or in any number of custom formats.</p>
211
212 <p>You can ask Catalina to create an access log for all requests
213 processed by an <a href="engine.html">Engine</a>,
214 <a href="host.html">Host</a>, or <a href="context.html">Context</a>
215 by nesting a <a href="valve.html">Valve</a> element like this:</p>
216
刘洪青6266f992017-05-15 21:21:03 +0800217<div class="codeBox"><pre><code>&lt;Engine name="Standalone" ...&gt;
Hongqing Liufd5ee812014-05-10 16:32:51 +0800218 ...
219 &lt;Valve className="org.apache.catalina.valves.AccessLogValve"
220 prefix="catalina_access_log." suffix=".txt"
221 pattern="common"/&gt;
222 ...
刘洪青6266f992017-05-15 21:21:03 +0800223&lt;/Engine&gt;</code></pre></div>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800224
刘洪青6266f992017-05-15 21:21:03 +0800225 <p>See <a href="valve.html#Access_Logging">Access Logging Valves</a>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800226 for more information on the configuration attributes that are
227 supported.</p>
228
229 </blockquote></td></tr></table>
230
231
232 <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Lifecycle Listeners"><!--()--></a><a name="Lifecycle_Listeners"><strong>Lifecycle Listeners</strong></a></font></td></tr><tr><td><blockquote>
233
234 <p>If you have implemented a Java object that needs to know when this
235 <strong>Engine</strong> is started or stopped, you can declare it by
236 nesting a <strong>Listener</strong> element inside this element. The
237 class name you specify must implement the
238 <code>org.apache.catalina.LifecycleListener</code> interface, and
239 it will be notified about the occurrence of the corresponding
240 lifecycle events. Configuration of such a listener looks like this:</p>
241
刘洪青6266f992017-05-15 21:21:03 +0800242<div class="codeBox"><pre><code>&lt;Engine name="Standalone" ...&gt;
Hongqing Liufd5ee812014-05-10 16:32:51 +0800243 ...
244 &lt;Listener className="com.mycompany.mypackage.MyListener" ... &gt;
245 ...
刘洪青6266f992017-05-15 21:21:03 +0800246&lt;/Engine&gt;</code></pre></div>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800247
248 <p>Note that a Listener can have any number of additional properties
249 that may be configured from this element. Attribute names are matched
250 to corresponding JavaBean property names using the standard property
251 method naming patterns.</p>
252
253 </blockquote></td></tr></table>
254
255
256 <table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#828DA6"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="Request Filters"><!--()--></a><a name="Request_Filters"><strong>Request Filters</strong></a></font></td></tr><tr><td><blockquote>
257
258 <p>You can ask Catalina to check the IP address, or host name, on every
259 incoming request directed to the surrounding
260 <a href="engine.html">Engine</a>, <a href="host.html">Host</a>, or
261 <a href="context.html">Context</a> element. The remote address or name
刘洪青6266f992017-05-15 21:21:03 +0800262 will be checked against configured "accept" and/or "deny"
Hongqing Liufd5ee812014-05-10 16:32:51 +0800263 filters, which are defined using <code>java.util.regex</code> Regular
264 Expression syntax. Requests that come from locations that are
265 not accepted will be rejected with an HTTP "Forbidden" error.
266 Example filter declarations:</p>
267
刘洪青6266f992017-05-15 21:21:03 +0800268<div class="codeBox"><pre><code>&lt;Engine name="Standalone" ...&gt;
Hongqing Liufd5ee812014-05-10 16:32:51 +0800269 ...
270 &lt;Valve className="org.apache.catalina.valves.RemoteHostValve"
271 allow=".*\.mycompany\.com|www\.yourcompany\.com"/&gt;
272 &lt;Valve className="org.apache.catalina.valves.RemoteAddrValve"
273 deny="192\.168\.1\.\d+"/&gt;
274 ...
刘洪青6266f992017-05-15 21:21:03 +0800275&lt;/Engine&gt;</code></pre></div>
Hongqing Liufd5ee812014-05-10 16:32:51 +0800276
刘洪青6266f992017-05-15 21:21:03 +0800277 <p>See <a href="valve.html#Remote_Address_Filter">Remote Address Filter</a>
278 and <a href="valve.html#Remote_Host_Filter">Remote Host Filter</a> for
Hongqing Liufd5ee812014-05-10 16:32:51 +0800279 more information about the configuration options that are supported.</p>
280
281 </blockquote></td></tr></table>
282
283
刘洪青6266f992017-05-15 21:21:03 +0800284</blockquote></td></tr></table></td></tr><tr class="noPrint"><td width="20%" valign="top" nowrap class="noPrint"></td><td width="80%" valign="top" align="left"><table border="0" cellspacing="0" cellpadding="2"><tr><td bgcolor="#525D76"><font color="#ffffff" face="arial,helvetica.sanserif"><a name="comments_section" id="comments_section"><strong>Comments</strong></a></font></td></tr><tr><td><blockquote><p class="notice"><strong>Notice: </strong>This comments section collects your suggestions
285 on improving documentation for Apache Tomcat.<br><br>
286 If you have trouble and need help, read
287 <a href="http://tomcat.apache.org/findhelp.html">Find Help</a> page
288 and ask your question on the tomcat-users
289 <a href="http://tomcat.apache.org/lists.html">mailing list</a>.
290 Do not ask such questions here. This is not a Q&amp;A section.<br><br>
291 The Apache Comments System is explained <a href="../comments.html">here</a>.
292 Comments may be removed by our moderators if they are either
293 implemented or considered invalid/off-topic.</p><script type="text/javascript"><!--//--><![CDATA[//><!--
294 var comments_shortname = 'tomcat';
295 var comments_identifier = 'http://tomcat.apache.org/tomcat-7.0-doc/config/engine.html';
296 (function(w, d) {
297 if (w.location.hostname.toLowerCase() == "tomcat.apache.org") {
298 d.write('<div id="comments_thread"><\/div>');
299 var s = d.createElement('script');
300 s.type = 'text/javascript';
301 s.async = true;
302 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
303 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
304 }
305 else {
306 d.write('<div id="comments_thread"><strong>Comments are disabled for this page at the moment.<\/strong><\/div>');
307 }
308 })(window, document);
309 //--><!]]></script></blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr noshade size="1"></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font color="#525D76" size="-1"><em>
310 Copyright &copy; 1999-2017, Apache Software Foundation
Hongqing Liufd5ee812014-05-10 16:32:51 +0800311 </em></font></div></td></tr></table></body></html>