Connector configuration in Tomcat

  • 2021-01-06 00:49:52
  • OfStack

JBoss uses Tomcat as the Web container, so the configuration of Web container in JBoss is similar to that in Tomcat, mainly the editing of the server.xml file, which is located in JBoss 5.x ${JBOSS.HOME}\server\${confifure}\deploy\jbossweb.sar Where the value of configure can be all, default,web, standard, minimal, etc. The following code shows an server.xml for an JBoss default configuration. The comments have been removed for space reasons.


<Server> 
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> 
  <Listener className="org.apache.catalina.core.JasperListener" /> 
  <Service name="jboss.web"> 
   <Connector protocol="HTTP/1.1" port="8080" address="${jboss.bind.address}"  
        connectionTimeout="20000" redirectPort="8443" compression="on"  
        compressionMinSize="1" compressableMimeType="text/html,text/xml" /> 
   <Engine name="jboss.web" defaultHost="localhost"> 
     <Realm className="org.jboss.web.tomcat.security.JBossWebRealm" 
      certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping" 
      allRolesMode="authOnly" 
      /> 
     <Host name="localhost">  
      <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve" 
      cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager" 
      transactionManagerObjectName="jboss:service=TransactionManager" /> 
     Host> 
   Engine> 
  Service> 
Server> 

In the configuration file above, Server is the root node, and one Server represents one Servlet container. Therefore, in server.xml, there can only be one such node, and under Server, there can be one or more Service nodes.

An Service node represents one or more Connector and one Engine, while Connector and Engine are two important configuration items in server.xml's main function is to accept and respond to user requests. HTTP/1.1 Connector and AJP Connector are commonly used. HTTP/1.1 Connector is mainly used to handle user HTTP requests. It should be noted that although it is called HTTP/1.1 Connector, it is fully compatible with the HTTP/1.0 protocol. AJP Connector mainly uses the AJP protocol and Web Connector communication, usually used in clusters.

HTTP / 1.1 Connector instance of listening on the port of user configuration, when the application server startup, HTTP / 1.1 Connector responsible for creating a number of threads, used to handle user requests, the number of threads created depends on the user configuration minThreads value, the default value is 5, when there are more user request arrival, HTTP / 1.1 Connector will create more threads to handle requests, to create the maximum thread by maxThreads definition, the default value is 20, when all the threads were busy handling user requests, New incoming requests will be placed in the Socket queue created by HTTP/1.1 Connector. The length of the queue is defined by the acceptCount attribute. When the waiting queue is full, new user requests will receive an connection refused error.

All Connector configuration items (incomplete scheme, isSecure, xpoweredBy, useIPVHosts) :

allowTrace If you want the server to be able to handle user HAED/TRACE requests, this value should be set to true, the default is false; If emptySessionPath is set to true, all session,cookie path will be set to /. This is usually useful in portlet. The default value is false. enableLookups If you want to get the name of the client machine when calling the request.getRemoteHost() method, you need to configure it to true. If configured to false, it will skip the DNS query and return the IP address of the client machine directly. maxPostSize The maximum size of data that can be submitted by the POST method. If undeclared or set to less than or equal to 0, this means that the size of data submitted by POST is unlimited. The default value is 2Megabytes. protocol set the protocol of processing request, default is HTTP / 1.1, namely org. apache. coyote. http11. Http11Protocol, moreover also supports the agreement include: org. apache. coyote. http11. Http11NioProtocol (through NIO handle user request, can improve the performance of the system), org. apache. coyote. http11. HttpAprProtocol. proxyName/proxyPort If the Web server uses a proxy server, configuring this parameter means that the name of the proxy server will be obtained when request.getServerName is called and getServerPort() will return proxyPort. If Connector is configured to support non-SSL requests, the server will automatically redirect the request to redirectPort when an SSL request arrives. false: ISO-8859-1 (ISO-8859-1) UTF-8 (GBK,GB2312) ISO-8859-1 (ISO-8859-1) useBodyEncodingForURI If set to true, the encoding of URI will be determined based on the encoding of the page. The default is false.

Http/1.1 Connector provides configuration items:

The length of the acceptCount wait queue. The default value is 100. address This value declares the IP address used to listen for HTTP requests if Tomcat is hosted on multiple IP hosts. bufferSize Connector The size of the input stream created by bufferSize. The default value is 2048 bytes. Increasing this value can increase performance and memory consumption. compressableMimeType use HTTP compression MIME type, use a comma split, the default value is text/html, text/xml, text/plain. compression To save bandwidth, you can set this value to on to enable HTTP/1.1 GZIP compression. off turns off compression. forces enforces compression. The default value is off. connectionTimeout The amount of time Connector will wait after accepting 1 connection (milliseconds). The default value is 60,000. The value of this property is the name of the configured Executor. If this property is applied and executor exists, any other thread configuration will be ignored. Connector: The number of subtlements Connector waits for another request Keep before Connector closes the connection. The default value is the same as connectionTimeout 1. maxHttpHeaderSize HTTP The maximum size of request and response headers. The default is 8192bytes. maxKeepAliveRequests HTTP/1.0 Keep Alive and HTTP/1.1 Keep Alive/Pipeline Maximum number of requests, if set to 1, will disable Keep Alive and Pipeline, if set to less than 0, there will be no limit to the maximum number of requests for Keep Alive. Default is 100. maxThreads is used to handle the maximum number of threads for user requests. The default value is 20. noCompressionUserAgents: Sets clients that do not use HTTP GZIP compression, separated by commas. This property can be used when some browsers do not support compression. port The port on which Connector listens. restrictedUserAgents sets the name of the client proxy that does not use Keep. It is separated by commas. The default value is an empty string. server overwrites serve headers for HTTP responses. The default value, if not set, is Apache-Coyote/1.1. This attribute is usually not a concern. socketBuffer Socket The size of the output stream buffer, the default is 9000bytes, if set to a value less than 0, this buffer is not used. tcpNoDelay The default value is true, set to true to improve system performance. The priority of the threadPriority request processing thread. The default priority is NORMAL.

conclusion


Related articles: