您的位置:首页 > 理论基础 > 计算机网络

Tomcat的HTTP和AJP连接器

2016-03-02 18:51 681 查看

在tomcat的server.xml文件中可以找到如下几个connector

<!-- 1. HTTP -->
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

<!-- 2. HTTPS -->
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
<!-- 3. AJP -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


1. HTTP Connector

The HTTP Connector element represents a Connector component that supports the HTTP/1.1 protocol.

此连接器支持HTTP/1.1协议

It enables Catalina to function as a stand-alone web server, in addition to its ability to execute servlets and JSP pages.

拥有这个连接器,tomcat才能成为一个web服务器,但还额外可处理servlet和jsp

A particular instance of this component listens for connections on a specific TCP port number on the server.

每个连接器监听一个你电脑上的TCP端口(而没有UPD端口)

One or more such Connectors can be configured as part of a single Service, each forwarding to the associated Engine to perform request processing and create the response.

一个Service可以配置多个HTTP连接器(配置不同端口即可),每个连接器都可以将请求转发到与它们同级的一个Engine上让它处理,并且让它生成相应。

2. AJP Connector

The AJP Connector element represents a Connector component that communicates with a web connector via the AJP protocol.

AJP连接器可以通过AJP协议和一个web容器进行交互

This is used for cases where you wish to invisibly integrate Tomcat into an existing (or new)Apache installation, and you want Apache to handle the static content contained in the web application, and/or utilize Apache’s SSL processing.

当你想让Apache和Tomcat结合并且你想让Apache处理静态内容的时候用AJP,或者你想利用Apache的SSL处理能力时

This connector supports load balancing when used in conjunction with the jvmRoute attribute of the Engine.

特殊于HTTP Connector,AJP还可以与engine元素上的jvmRoute结合使用来实现负载均衡功能

我看的tomcat8.0.30的版本的AJP连接器支持JK 1.2.X和mode_proxy(on Apache httpd 2.x)两种方式与其他web容器交互(一般使用Apache HTTP Server)

3. HTTPS Connector

暂且不表

TIPS:

1. tomcat默认的服务(1级) Server使用8005端口,它可以包含多个Service

2. 默认的那个(2级) Service的name叫catalina,它可以拥有多种连接器(3级) Connector,每种连接器可以拥有多个

3. Service中可以有(3级) 一个Engine,与Connector同级

相关内容可在每个tomcat的webapps默认项目docs中找到,相对路径:apache-tomcat-x.x.xx/webapps/docs/config/http.html

结论

其实这篇文章是Apache和Tomcat结合配置的前置文章,通过看文档,知道了Apache和Tomcat结合的时候:

1. Apache会拦截所有请求,将servlet和JSP(.jsp结尾)请求通过AJP交给Tomcat处理,然后再把结果拿到Apache然后返回

2. 将静态资源的访问,(类似.html/.css/.jpg等之类的结尾)自己直接处理不交给tomcat,直接返回

3. Apache和Tomcat结合之后:Tomcat的HTTP Connector永远不会被用到了,可以没有

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: