博客
关于我
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 中随机抽样:order by rand limit 的替代方案
查看>>
MySQL 为什么需要两阶段提交?
查看>>
mysql 为某个字段的值加前缀、去掉前缀
查看>>
mysql 主从
查看>>
mysql 主从 lock_mysql 主从同步权限mysql 行锁的实现
查看>>
mysql 主从互备份_mysql互为主从实战设置详解及自动化备份(Centos7.2)
查看>>
mysql 主从关系切换
查看>>
MYSQL 主从同步文档的大坑
查看>>
mysql 主键重复则覆盖_数据库主键不能重复
查看>>
Mysql 事务知识点与优化建议
查看>>
Mysql 优化 or
查看>>
mysql 优化器 key_mysql – 选择*和查询优化器
查看>>
MySQL 优化:Explain 执行计划详解
查看>>
Mysql 会导致锁表的语法
查看>>
mysql 使用sql文件恢复数据库
查看>>
mysql 修改默认字符集为utf8
查看>>
Mysql 共享锁
查看>>
MySQL 内核深度优化
查看>>
mysql 内连接、自然连接、外连接的区别
查看>>