Connector配置
Connector 属于 StandardService 里的一个组件,可以在 server.xml 中配置,指定协议、端口、超时时间等。1
2
3
4<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
</Service>
每个 Service 里可以配置多个 Connector. Tomcat 的 Connector 支持两种协议,HTTP 和 AJP. 关于这两种协议,官方文档如此说:
- The HTTP connector is setup by default with Tomcat, and is ready to use. This connector features the lowest latency and best overall performance.
- When using a single server, the performance when using a native webserver in front of the Tomcat instance is most of the time significantly worse than a standalone Tomcat with its default HTTP connector, even if a large part of the web application is made of static files. If integration with the native webserver is needed for any reason, an AJP connector will provide faster performance than proxied HTTP. AJP clustering is the most efficient from the Tomcat perspective. It is otherwise functionally equivalent to HTTP clustering.