博客
关于我
Tomcat的HTTP和AJP连接器
阅读量:340 次
发布时间:2019-03-04

本文共 2403 字,大约阅读时间需要 8 分钟。

在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
2
3
4
5
6
7
8
9
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永远不会被用到了,可以没有
 

转载地址:http://twie.baihongyu.com/

你可能感兴趣的文章
MySQL 索引的面试题总结
查看>>
mysql 索引类型以及创建
查看>>
MySQL 索引连环问题,你能答对几个?
查看>>
Mysql 索引问题集锦
查看>>
Mysql 纵表转换为横表
查看>>
mysql 编译安装 window篇
查看>>
mysql 网络目录_联机目录数据库
查看>>
MySQL 聚簇索引&&二级索引&&辅助索引
查看>>
Mysql 脏页 脏读 脏数据
查看>>
mysql 自增id和UUID做主键性能分析,及最优方案
查看>>
Mysql 自定义函数
查看>>
mysql 行转列 列转行
查看>>
Mysql 表分区
查看>>
mysql 表的操作
查看>>
mysql 视图,视图更新删除
查看>>
MySQL 触发器
查看>>
mysql 让所有IP访问数据库
查看>>
mysql 记录的增删改查
查看>>
MySQL 设置数据库的隔离级别
查看>>
MySQL 证明为什么用limit时,offset很大会影响性能
查看>>