[66] | 1 | <html><head><META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Apache Tomcat Configuration Reference - The Host Container</title><meta value="Craig R. McClanahan" name="author"><meta value="craigmcc@apache.org" name="email"><meta value="Remy Maucherat" name="author"><meta value="remm@apache.org" name="email"><meta value="Yoav Shapira" name="author"><meta value="yoavs@apache.org" name="email"></head><body vlink="#525D76" alink="#525D76" link="#525D76" text="#000000" bgcolor="#ffffff"><table cellspacing="0" width="100%" border="0"><!--PAGE HEADER--><tr><td><!--PROJECT LOGO--><a href="http://tomcat.apache.org/"><img border="0" alt=" |
---|
| 2 | The Apache Tomcat Servlet/JSP Container |
---|
| 3 | " align="right" src="../../images/tomcat.gif"></a></td><td><font face="arial,helvetica,sanserif"><h1>Apache Tomcat 6.0</h1></font></td><td><!--APACHE LOGO--><a href="http://www.apache.org/"><img border="0" alt="Apache Logo" align="right" src="../../images/asf-logo.gif"></a></td></tr></table><table cellspacing="4" width="100%" border="0"><!--HEADER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><tr><!--RIGHT SIDE MAIN BODY--><td align="left" valign="top" width="80%"><table cellspacing="4" width="100%" border="0"><tr><td valign="top" align="left"><h1>Apache Tomcat Configuration Reference</h1><h2>The Host Container</h2></td><td nowrap="true" valign="top" align="right"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Introduction"><strong>Introduction</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 4 | |
---|
| 5 | <p>The <strong>Host</strong> element represents a <em>virtual host</em>, |
---|
| 6 | which is an association of a network name for a server (such as |
---|
| 7 | "www.mycompany.com" with the particular server on which Catalina is |
---|
| 8 | running. In order to be effective, this name must be registered in the |
---|
| 9 | <em>Domain Name Service</em> (DNS) server that manages the Internet |
---|
| 10 | domain you belong to - contact your Network Administrator for more |
---|
| 11 | information.</p> |
---|
| 12 | |
---|
| 13 | <p>In many cases, System Administrators wish to associate more than |
---|
| 14 | one network name (such as <code>www.mycompany.com</code> and |
---|
| 15 | <code>company.com</code>) with the same virtual host and applications. |
---|
| 16 | This can be accomplished using the <a href="#Host Name Aliases">Host |
---|
| 17 | Name Aliases</a> feature discussed below.</p> |
---|
| 18 | |
---|
| 19 | <p>One or more <strong>Host</strong> elements are nested inside an |
---|
| 20 | <a href="engine.html">Engine</a> element. Inside the Host element, you |
---|
| 21 | can nest <a href="context.html">Context</a> elements for the web |
---|
| 22 | applications associated with this virtual host. Exactly one of the Hosts |
---|
| 23 | associated with each Engine MUST have a name matching the |
---|
| 24 | <code>defaultHost</code> attribute of that Engine.</p> |
---|
| 25 | |
---|
| 26 | <blockquote><em> |
---|
| 27 | <p>The description below uses the variable name $CATALINA_BASE to refer the |
---|
| 28 | base directory against which most relative paths are resolved. If you have |
---|
| 29 | not configured Tomcat 6 for multiple instances by setting a CATALINA_BASE |
---|
| 30 | directory, then $CATALINA_BASE will be set to the value of $CATALINA_HOME, |
---|
| 31 | the directory into which you have installed Tomcat 6.</p> |
---|
| 32 | </em></blockquote> |
---|
| 33 | |
---|
| 34 | </blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Attributes"><strong>Attributes</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 35 | |
---|
| 36 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Common Attributes"><strong>Common Attributes</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 37 | |
---|
| 38 | <p>All implementations of <strong>Host</strong> |
---|
| 39 | support the following attributes:</p> |
---|
| 40 | |
---|
| 41 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><strong><code>appBase</code></strong></td><td valign="center" align="left"> |
---|
| 42 | <p>The <em>Application Base</em> directory for this virtual host. |
---|
| 43 | This is the pathname of a directory that may contain web applications |
---|
| 44 | to be deployed on this virtual host. You may specify an |
---|
| 45 | absolute pathname for this directory, or a pathname that is relative |
---|
| 46 | to the <code>$CATALINA_BASE</code> directory. See |
---|
| 47 | <a href="#Automatic Application Deployment">Automatic Application |
---|
| 48 | Deployment</a> for more information on automatic recognition and |
---|
| 49 | deployment of web applications to be deployed automatically.</p> |
---|
| 50 | </td></tr><tr><td valign="center" align="left"><code>autoDeploy</code></td><td valign="center" align="left"> |
---|
| 51 | <p>This flag value indicates if new web applications, dropped in to |
---|
| 52 | the <code>appBase</code> directory while Tomcat is running, should |
---|
| 53 | be automatically deployed. The flag's value defaults to true. See |
---|
| 54 | <a href="#Automatic Application Deployment">Automatic Application |
---|
| 55 | Deployment</a> for more information.</p> |
---|
| 56 | </td></tr><tr><td valign="center" align="left"><code>backgroundProcessorDelay</code></td><td valign="center" align="left"> |
---|
| 57 | <p>This value represents the delay in seconds between the |
---|
| 58 | invocation of the backgroundProcess method on this host and |
---|
| 59 | its child containers, including all contexts. |
---|
| 60 | Child containers will not be invoked if their delay value is not |
---|
| 61 | negative (which would mean they are using their own processing |
---|
| 62 | thread). Setting this to a positive value will cause |
---|
| 63 | a thread to be spawn. After waiting the specified amount of time, |
---|
| 64 | the thread will invoke the backgroundProcess method on this host |
---|
| 65 | and all its child containers. A host will use background processing to |
---|
| 66 | perform live web application deployment related tasks. If not |
---|
| 67 | specified, the default value for this attribute is -1, which means |
---|
| 68 | the host will rely on the background processing thread of its parent |
---|
| 69 | engine.</p> |
---|
| 70 | </td></tr><tr><td valign="center" align="left"><code>className</code></td><td valign="center" align="left"> |
---|
| 71 | <p>Java class name of the implementation to use. This class must |
---|
| 72 | implement the <code>org.apache.catalina.Host</code> interface. |
---|
| 73 | If not specified, the standard value (defined below) will be used.</p> |
---|
| 74 | </td></tr><tr><td valign="center" align="left"><code>deployOnStartup</code></td><td valign="center" align="left"> |
---|
| 75 | <p>This flag value indicates if web applications from this host should |
---|
| 76 | be automatically deployed by the host configurator. |
---|
| 77 | The flag's value defaults to true. See |
---|
| 78 | <a href="#Automatic Application Deployment">Automatic Application |
---|
| 79 | Deployment</a> for more information.</p> |
---|
| 80 | </td></tr><tr><td valign="center" align="left"><strong><code>name</code></strong></td><td valign="center" align="left"> |
---|
| 81 | <p>Network name of this virtual host, as registered in your |
---|
| 82 | <em>Domain Name Service</em> server. One of the Hosts nested within |
---|
| 83 | an <a href="engine.html">Engine</a> MUST have a name that matches the |
---|
| 84 | <code>defaultHost</code> setting for that Engine. See |
---|
| 85 | <a href="#Host Name Aliases">Host Name Aliases</a> for information |
---|
| 86 | on how to assign more than one network name to the same |
---|
| 87 | virtual host.</p> |
---|
| 88 | </td></tr></table> |
---|
| 89 | |
---|
| 90 | </blockquote></td></tr></table> |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Standard Implementation"><strong>Standard Implementation</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 94 | |
---|
| 95 | <p>The standard implementation of <strong>Host</strong> is |
---|
| 96 | <strong>org.apache.catalina.core.StandardHost</strong>. |
---|
| 97 | It supports the following additional attributes (in addition to the |
---|
| 98 | common attributes listed above):</p> |
---|
| 99 | |
---|
| 100 | <table cellpadding="5" border="1"><tr><th bgcolor="#023264" width="15%"><font color="#ffffff">Attribute</font></th><th bgcolor="#023264" width="85%"><font color="#ffffff">Description</font></th></tr><tr><td valign="center" align="left"><code>deployXML</code></td><td valign="center" align="left"> |
---|
| 101 | <p>Set to <code>false</code> if you want to disable parsing the context.xml |
---|
| 102 | file embedded inside the application (located at <code>/META-INF/context.xml</code>). |
---|
| 103 | Security consious environments should set this to <code>false</code> to prevent |
---|
| 104 | applications from interacting with the container's configuration. The |
---|
| 105 | administrator will then be responsible for providing an external context |
---|
| 106 | configuration file, and put it in |
---|
| 107 | <code>$CATALINA_BASE/conf/[enginename]/[hostname]/</code>. |
---|
| 108 | The flag's value defaults to <code>true</code>.</p> |
---|
| 109 | </td></tr><tr><td valign="center" align="left"><code>errorReportValveClass</code></td><td valign="center" align="left"> |
---|
| 110 | <p>Java class name of the error reporting valve which will be used |
---|
| 111 | by this Host. The responsability of this valve is to output error |
---|
| 112 | reports. Setting this property allows to customize the look of the |
---|
| 113 | error pages which will be generated by Tomcat. This class must |
---|
| 114 | implement the |
---|
| 115 | <code>org.apache.catalina.Valve</code> interface. If none is specified, |
---|
| 116 | the value <code>org.apache.catalina.valves.ErrorReportValve</code> |
---|
| 117 | will be used by default.</p> |
---|
| 118 | </td></tr><tr><td valign="center" align="left"><code>unpackWARs</code></td><td valign="center" align="left"> |
---|
| 119 | <p>Set to <code>true</code> if you want web applications that are |
---|
| 120 | placed in the <code>appBase</code> directory as web application |
---|
| 121 | archive (WAR) files to be unpacked into a corresponding disk directory |
---|
| 122 | structure, <code>false</code> to run such web applications directly |
---|
| 123 | from a WAR file. See |
---|
| 124 | <a href="#Automatic Application Deployment">Automatic Application |
---|
| 125 | Deployment</a> for more information.</p> |
---|
| 126 | </td></tr><tr><td valign="center" align="left"><code>workDir</code></td><td valign="center" align="left"> |
---|
| 127 | <p>Pathname to a scratch directory to be used by applications for |
---|
| 128 | this Host. Each application will have its own sub directory with |
---|
| 129 | temporary read-write use. Configuring a Context workDir will override |
---|
| 130 | use of the Host workDir configuration. This directory will be made |
---|
| 131 | visible to servlets in the web application by a servlet context |
---|
| 132 | attribute (of type <code>java.io.File</code>) named |
---|
| 133 | <code>javax.servlet.context.tempdir</code> as described in the |
---|
| 134 | Servlet Specification. If not specified, a suitable directory |
---|
| 135 | underneath <code>$CATALINA_BASE/work</code> will be provided.</p> |
---|
| 136 | </td></tr></table> |
---|
| 137 | |
---|
| 138 | </blockquote></td></tr></table> |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | </blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Nested Components"><strong>Nested Components</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 142 | |
---|
| 143 | <p>You can nest one or more <a href="context.html">Context</a> elements |
---|
| 144 | inside this <strong>Host</strong> element, each representing a different web |
---|
| 145 | application associated with this virtual host.</p> |
---|
| 146 | |
---|
| 147 | <p>You can nest at most one instance of the following utility components |
---|
| 148 | by nesting a corresponding element inside your <strong>Host</strong> |
---|
| 149 | element:</p> |
---|
| 150 | <ul> |
---|
| 151 | <li><a href="realm.html"><strong>Realm</strong></a> - |
---|
| 152 | Configure a realm that will allow its |
---|
| 153 | database of users, and their associated roles, to be shared across all |
---|
| 154 | <a href="context.html">Contexts</a> nested inside this Host (unless |
---|
| 155 | overridden by a <a href="realm.html">Realm</a> configuration |
---|
| 156 | at a lower level).</li> |
---|
| 157 | </ul> |
---|
| 158 | |
---|
| 159 | </blockquote></td></tr></table><table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#525D76"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Special Features"><strong>Special Features</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Logging"><strong>Logging</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 163 | |
---|
| 164 | <p>A host is associated with the |
---|
| 165 | <code>org.apache.catalina.core.ContainerBase.[enginename].[hostname]</code> |
---|
| 166 | log category. Note that the brackets are actuall part of the name, |
---|
| 167 | don't omit them.</p> |
---|
| 168 | |
---|
| 169 | </blockquote></td></tr></table> |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Access Logs"><strong>Access Logs</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 173 | |
---|
| 174 | <p>When you run a web server, one of the output files normally generated |
---|
| 175 | is an <em>access log</em>, which generates one line of information for |
---|
| 176 | each request processed by the server, in a standard format. Catalina |
---|
| 177 | includes an optional <a href="valve.html">Valve</a> implementation that |
---|
| 178 | can create access logs in the same standard format created by web servers, |
---|
| 179 | or in any number of custom formats.</p> |
---|
| 180 | |
---|
| 181 | <p>You can ask Catalina to create an access log for all requests |
---|
| 182 | processed by an <a href="engine.html">Engine</a>, |
---|
| 183 | <a href="host.html">Host</a>, or <a href="context.html">Context</a> |
---|
| 184 | by nesting a <a href="valve.html">Valve</a> element like this:</p> |
---|
| 185 | |
---|
| 186 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 187 | <Host name="localhost" ...> |
---|
| 188 | ... |
---|
| 189 | <Valve className="org.apache.catalina.valves.AccessLogValve" |
---|
| 190 | prefix="localhost_access_log." suffix=".txt" |
---|
| 191 | pattern="common"/> |
---|
| 192 | ... |
---|
| 193 | </Host> |
---|
| 194 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 195 | |
---|
| 196 | <p>See <a href="valve.html#Access Log Valve">Access Log Valve</a> |
---|
| 197 | for more information on the configuration attributes that are |
---|
| 198 | supported.</p> |
---|
| 199 | |
---|
| 200 | </blockquote></td></tr></table> |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Automatic Application Deployment"><strong>Automatic Application Deployment</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 204 | |
---|
| 205 | <p>If you are using the standard <strong>Host</strong> implementation, |
---|
| 206 | the following actions take place automatically when Catalina is first |
---|
| 207 | started, if the <code>deployOnStartup</code> property is set to |
---|
| 208 | <code>true</code> (which is the default value):</p> |
---|
| 209 | <ul> |
---|
| 210 | <li>Any XML file in the |
---|
| 211 | <code>$CATALINA_BASE/conf/[engine_name]/[host_name]</code> directory is |
---|
| 212 | assumed to contain a |
---|
| 213 | <a href="context.html">Context</a> element (and its associated |
---|
| 214 | subelements) for a single web application. The <code>docBase</code> |
---|
| 215 | attribute of this <code><Context></code> element will typically |
---|
| 216 | be the absolute pathname to a web application directory, or the |
---|
| 217 | absolute pathname of a web application archive (WAR) file (which |
---|
| 218 | will not be expanded). The path attribute will be automatically set |
---|
| 219 | as defined in the <a href="context.html">Context</a> documentation.</li> |
---|
| 220 | <li>Any web application archive file within the application base (appBase) |
---|
| 221 | directory that does not have a corresponding |
---|
| 222 | directory of the same name (without the ".war" extension) will be |
---|
| 223 | automatically expanded, unless the <code>unpackWARs</code> property |
---|
| 224 | is set to <code>false</code>. If you redeploy an updated WAR file, |
---|
| 225 | be sure to delete the expanded directory when restarting Tomcat, so |
---|
| 226 | that the updated WAR file will be re-expanded (note that the auto |
---|
| 227 | deployer, if enabled, will automatically expand the updated WAR file |
---|
| 228 | once the previously expanded directory is removed).</li> |
---|
| 229 | <li>Any subdirectory within the <em>application base directory</em> |
---|
| 230 | will receive an automatically generated <a href="context.html"> |
---|
| 231 | Context</a> element, even if this directory is not mentioned in the |
---|
| 232 | <code>conf/server.xml</code> file. |
---|
| 233 | This generated Context entry will be configured according to the |
---|
| 234 | properties set in any <a href="defaultcontext.html">DefaultContext</a> |
---|
| 235 | element nested in this Host element. The context path for this |
---|
| 236 | deployed Context will be a slash character ("/") followed by the |
---|
| 237 | directory name, unless the directory name is ROOT, in which case |
---|
| 238 | the context path will be an empty string ("").</li> |
---|
| 239 | </ul> |
---|
| 240 | |
---|
| 241 | <p>In addition to the automatic deployment that occurs at startup time, |
---|
| 242 | you can also request that new XML configuration files, WAR files, or |
---|
| 243 | subdirectories that are dropped in to the <code>appBase</code> (or |
---|
| 244 | <code>$CATALINA_BASE/conf/[engine_name]/[host_name]</code> in the case of |
---|
| 245 | an XML configuration file) directory while Tomcat is running will be |
---|
| 246 | automatically deployed, according to the rules described above. The |
---|
| 247 | auto deployer will also track web applications for the following changes: |
---|
| 248 | <ul> |
---|
| 249 | <li>An update to the WEB-INF/web.xml file will trigger a reload of the |
---|
| 250 | web application</li> |
---|
| 251 | <li>An update to a WAR which has been expanded will trigger |
---|
| 252 | an undeploy (<strong>with a removal of the expanded webapp</strong>), |
---|
| 253 | followed by a deployment</li> |
---|
| 254 | <li>An update to a XML configuration file will trigger an undeploy |
---|
| 255 | (without the removal of any expanded directory), followed by |
---|
| 256 | a deployment of the associated web application</li> |
---|
| 257 | </ul> |
---|
| 258 | </p> |
---|
| 259 | |
---|
| 260 | <p>When using automatic deployment, the <code>docBase</code> defined by |
---|
| 261 | an XML <a href="context.html">Context</a> file should be outside of the |
---|
| 262 | <code>appBase</code> directory. If this is not the case difficulties |
---|
| 263 | may be experienced deploying the web application or the application may |
---|
| 264 | be deployed twice.</p> |
---|
| 265 | |
---|
| 266 | <p>Finally, note that if you are defining contexts explicitly, you should |
---|
| 267 | probably turn off automatic application deployment. Otherwise, your context |
---|
| 268 | will be deployed twice each, and that may cause problems for your app. |
---|
| 269 | </p> |
---|
| 270 | |
---|
| 271 | </blockquote></td></tr></table> |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Host Name Aliases"><strong>Host Name Aliases</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 275 | |
---|
| 276 | <p>In many server environments, Network Administrators have configured |
---|
| 277 | more than one network name (in the <em>Domain Name Service</em> (DNS) |
---|
| 278 | server), that resolve to the IP address of the same server. Normally, |
---|
| 279 | each such network name would be configured as a separate |
---|
| 280 | <strong>Host</strong> element in <code>conf/server.xml</code>, each |
---|
| 281 | with its own set of web applications.</p> |
---|
| 282 | |
---|
| 283 | <p>However, in some circumstances, it is desireable that two or more |
---|
| 284 | network names should resolve to the <strong>same</strong> virtual host, |
---|
| 285 | running the same set of applications. A common use case for this |
---|
| 286 | scenario is a corporate web site, where it is desireable that users |
---|
| 287 | be able to utilize either <code>www.mycompany.com</code> or |
---|
| 288 | <code>company.com</code> to access exactly the same content and |
---|
| 289 | applications.</p> |
---|
| 290 | |
---|
| 291 | <p>This is accomplished by utilizing one or more <strong>Alias</strong> |
---|
| 292 | elements nested inside your <strong>Host</strong> element. For |
---|
| 293 | example:</p> |
---|
| 294 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 295 | <Host name="www.mycompany.com" ...> |
---|
| 296 | ... |
---|
| 297 | <Alias>mycompany.com</Alias> |
---|
| 298 | ... |
---|
| 299 | </Host> |
---|
| 300 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 301 | |
---|
| 302 | <p>In order for this strategy to be effective, all of the network names |
---|
| 303 | involved must be registered in your DNS server to resolve to the |
---|
| 304 | same computer that is running this instance of Catalina.</p> |
---|
| 305 | |
---|
| 306 | </blockquote></td></tr></table> |
---|
| 307 | |
---|
| 308 | |
---|
| 309 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Lifecycle Listeners"><strong>Lifecycle Listeners</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 310 | |
---|
| 311 | <p>If you have implemented a Java object that needs to know when this |
---|
| 312 | <strong>Host</strong> is started or stopped, you can declare it by |
---|
| 313 | nesting a <strong>Listener</strong> element inside this element. The |
---|
| 314 | class name you specify must implement the |
---|
| 315 | <code>org.apache.catalina.LifecycleListener</code> interface, and |
---|
| 316 | it will be notified about the occurrence of the coresponding |
---|
| 317 | lifecycle events. Configuration of such a listener looks like this:</p> |
---|
| 318 | |
---|
| 319 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 320 | <Host name="localhost" ...> |
---|
| 321 | ... |
---|
| 322 | <Listener className="com.mycompany.mypackage.MyListener" ... > |
---|
| 323 | ... |
---|
| 324 | </Host> |
---|
| 325 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 326 | |
---|
| 327 | <p>Note that a Listener can have any number of additional properties |
---|
| 328 | that may be configured from this element. Attribute names are matched |
---|
| 329 | to corresponding JavaBean property names using the standard property |
---|
| 330 | method naming patterns.</p> |
---|
| 331 | |
---|
| 332 | </blockquote></td></tr></table> |
---|
| 333 | |
---|
| 334 | |
---|
| 335 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Request Filters"><strong>Request Filters</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 336 | |
---|
| 337 | <p>You can ask Catalina to check the IP address, or host name, on every |
---|
| 338 | incoming request directed to the surrounding |
---|
| 339 | <a href="engine.html">Engine</a>, <a href="host.html">Host</a>, or |
---|
| 340 | <a href="context.html">Context</a> element. The remote address or name |
---|
| 341 | will be checked against a configured list of "accept" and/or "deny" |
---|
| 342 | filters, which are defined using the Regular Expression syntax supported |
---|
| 343 | by the <a href="http://jakarta.apache.org/regexp/">Jakarta Regexp</a> |
---|
| 344 | regular expression library. Requests that come from locations that are |
---|
| 345 | not accepted will be rejected with an HTTP "Forbidden" error. |
---|
| 346 | Example filter declarations:</p> |
---|
| 347 | |
---|
| 348 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 349 | <Host name="localhost" ...> |
---|
| 350 | ... |
---|
| 351 | <Valve className="org.apache.catalina.valves.RemoteHostValve" |
---|
| 352 | allow="*.mycompany.com,www.yourcompany.com"/> |
---|
| 353 | <Valve className="org.apache.catalina.valves.RemoteAddrValve" |
---|
| 354 | deny="192.168.1.*"/> |
---|
| 355 | ... |
---|
| 356 | </Host> |
---|
| 357 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 358 | |
---|
| 359 | <p>See <a href="valve.html#Remote Address Filter">Remote Address Filter</a> |
---|
| 360 | and <a href="valve.html#Remote Host Filter">Remote Host Filter</a> for |
---|
| 361 | more information about the configuration options that are supported.</p> |
---|
| 362 | |
---|
| 363 | </blockquote></td></tr></table> |
---|
| 364 | |
---|
| 365 | |
---|
| 366 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="Single Sign On"><strong>Single Sign On</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 367 | |
---|
| 368 | <p>In many environments, but particularly in portal environments, it |
---|
| 369 | is desireable to have a user challenged to authenticate themselves only |
---|
| 370 | once over a set of web applications deployed on a particular virtual |
---|
| 371 | host. This can be accomplished by nesting an element like this inside |
---|
| 372 | the Host element for this virtual host:</p> |
---|
| 373 | |
---|
| 374 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 375 | <Host name="localhost" ...> |
---|
| 376 | ... |
---|
| 377 | <Valve className="org.apache.catalina.authenticator.SingleSignOn" |
---|
| 378 | debug="0"/> |
---|
| 379 | ... |
---|
| 380 | </Host> |
---|
| 381 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 382 | |
---|
| 383 | <p>The Single Sign On facility operates according to the following rules: |
---|
| 384 | </p> |
---|
| 385 | <ul> |
---|
| 386 | <li>All web applications configured for this virtual host must share the |
---|
| 387 | same <a href="realm.html">Realm</a>. In practice, that means you can |
---|
| 388 | nest the Realm element inside this Host element (or the surrounding |
---|
| 389 | <a href="engine.html">Engine</a> element), but not inside a |
---|
| 390 | <a href="context.html">Context</a> element for one of the involved |
---|
| 391 | web applications.</li> |
---|
| 392 | <li>As long as the user accesses only unprotected resources in any of the |
---|
| 393 | web applications on this virtual host, they will not be challenged |
---|
| 394 | to authenticate themselves.</li> |
---|
| 395 | <li>As soon as the user accesses a protected resource in |
---|
| 396 | <strong>any</strong> web application associated with this virtual |
---|
| 397 | host, the user will be challenged to authenticate himself or herself, |
---|
| 398 | using the login method defined for the web application currently |
---|
| 399 | being accessed.</li> |
---|
| 400 | <li>Once authenticated, the roles associated with this user will be |
---|
| 401 | utilized for access control decisions across <strong>all</strong> |
---|
| 402 | of the associated web applications, without challenging the user |
---|
| 403 | to authenticate themselves to each application individually.</li> |
---|
| 404 | <li>As soon as the user logs out of one web application (for example, |
---|
| 405 | by invalidating the corresponding session if form |
---|
| 406 | based login is used), the user's sessions in <strong>all</strong> |
---|
| 407 | web applications will be invalidated. Any subsequent attempt to |
---|
| 408 | access a protected resource in any application will require the |
---|
| 409 | user to authenticate himself or herself again.</li> |
---|
| 410 | <li>The Single Sign On feature utilizes HTTP cookies to transmit a token |
---|
| 411 | that associates each request with the saved user identity, so it can |
---|
| 412 | only be utilized in client environments that support cookies.</li> |
---|
| 413 | </ul> |
---|
| 414 | |
---|
| 415 | </blockquote></td></tr></table> |
---|
| 416 | |
---|
| 417 | |
---|
| 418 | <table cellpadding="2" cellspacing="0" border="0"><tr><td bgcolor="#828DA6"><font face="arial,helvetica.sanserif" color="#ffffff"><a name="User Web Applications"><strong>User Web Applications</strong></a></font></td></tr><tr><td><blockquote> |
---|
| 419 | |
---|
| 420 | <p>Many web servers can automatically map a request URI starting with |
---|
| 421 | a tilde character ("~") and a username to a directory (commonly named |
---|
| 422 | <code>public_html</code>) in that user's home directory on the server. |
---|
| 423 | You can accomplish the same thing in Catalina by using a special |
---|
| 424 | <strong>Listener</strong> element like this (on a Unix system that |
---|
| 425 | uses the <code>/etc/passwd</code> file to identify valid users):</p> |
---|
| 426 | |
---|
| 427 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 428 | <Host name="localhost" ...> |
---|
| 429 | ... |
---|
| 430 | <Listener className="org.apache.catalina.startup.UserConfig" |
---|
| 431 | directoryName="public_html" |
---|
| 432 | userClass="org.apache.catalina.startup.PasswdUserDatabase"/> |
---|
| 433 | ... |
---|
| 434 | </Host> |
---|
| 435 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 436 | |
---|
| 437 | <p>On a server where <code>/etc/passwd</code> is not in use, you can |
---|
| 438 | request Catalina to consider all directories found in a specified base |
---|
| 439 | directory (such as <code>c:\Homes</code> in this example) to be |
---|
| 440 | considered "user home" directories for the purposes of this directive:</p> |
---|
| 441 | |
---|
| 442 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 443 | <Host name="localhost" ...> |
---|
| 444 | ... |
---|
| 445 | <Listener className="org.apache.catalina.startup.UserConfig" |
---|
| 446 | directoryName="public_html" |
---|
| 447 | homeBase=c:\Homes" |
---|
| 448 | userClass="org.apache.catalina.startup.HomesUserDatabase"/> |
---|
| 449 | ... |
---|
| 450 | </Host> |
---|
| 451 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 452 | |
---|
| 453 | <p>If a user home directory has been set up for a user named |
---|
| 454 | <code>craigmcc</code>, then its contents will be visible from a |
---|
| 455 | client browser by making a request to a URL like:</p> |
---|
| 456 | |
---|
| 457 | <div align="left"><table border="0" cellpadding="0" cellspacing="4"><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#ffffff"><pre> |
---|
| 458 | http://www.mycompany.com:8080/~craigmcc |
---|
| 459 | </pre></td><td width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr><tr><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td><td height="1" width="1" bgcolor="#023264"><img border="0" hspace="0" vspace="0" height="1" width="1" src="../../images/void.gif"></td></tr></table></div> |
---|
| 460 | |
---|
| 461 | <p>Successful use of this feature requires recognition of the following |
---|
| 462 | considerations:</p> |
---|
| 463 | <ul> |
---|
| 464 | <li>Each user web application will be deployed with characteristics |
---|
| 465 | established by any <a href="defaultcontext.html">DefaultContext</a> |
---|
| 466 | element you have configured for this Host.</li> |
---|
| 467 | <li>It is legal to include more than one instance of this Listener |
---|
| 468 | element. This would only be useful, however, in circumstances |
---|
| 469 | where you wanted to configure more than one "homeBase" directory.</li> |
---|
| 470 | <li>The operating system username under which Catalina is executed |
---|
| 471 | MUST have read access to each user's web application directory, |
---|
| 472 | and all of its contents.</li> |
---|
| 473 | </ul> |
---|
| 474 | |
---|
| 475 | </blockquote></td></tr></table> |
---|
| 476 | |
---|
| 477 | |
---|
| 478 | </blockquote></td></tr></table></td></tr><!--FOOTER SEPARATOR--><tr><td colspan="2"><hr size="1" noshade></td></tr><!--PAGE FOOTER--><tr><td colspan="2"><div align="center"><font size="-1" color="#525D76"><em> |
---|
| 479 | Copyright © 1999-2008, Apache Software Foundation |
---|
| 480 | </em></font></div></td></tr></table></body></html> |
---|