Tomcat的HTTP和AJP连接器

在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

  1. The HTTP Connector element represents a Connector component that supports the HTTP/1.1 protocol.
    此连接器支持HTTP/1.1协议

  2. 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

  3. A particular instance of this component listens for connections on a specific TCP port number on the server.
    每个连接器监听一个你电脑上的TCP端口(而没有UPD端口)

  4. 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

  1. The AJP Connector element represents a Connector component that communicates with a web connector via the AJP protocol.
    AJP连接器可以通过AJP协议和一个web容器进行交互

  2. 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处理能力时

  3. This connector supports load balancing when used in conjunction with the jvmRoute attribute of the Engine.
    特殊于HTTP Connector,AJP还可以与engine元素上的jvmRoute结合使用来实现负载均衡功能

  4. 我看的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永远不会被用到了,可以没有
  • 8
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值