博客
关于我
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:基础——3N范式的表结构设计
查看>>
MYSQL:基础——触发器
查看>>
Mysql:连接报错“closing inbound before receiving peer‘s close_notify”
查看>>
mysqlbinlog报错unknown variable ‘default-character-set=utf8mb4‘
查看>>
mysqldump 参数--lock-tables浅析
查看>>
mysqldump 导出中文乱码
查看>>
mysqldump 导出数据库中每张表的前n条
查看>>
mysqldump: Got error: 1044: Access denied for user ‘xx’@’xx’ to database ‘xx’ when using LOCK TABLES
查看>>
Mysqldump参数大全(参数来源于mysql5.5.19源码)
查看>>
mysqldump备份时忽略某些表
查看>>
mysqldump实现数据备份及灾难恢复
查看>>
mysqldump数据库备份无法进行操作只能查询 --single-transaction
查看>>
mysqldump的一些用法
查看>>
mysqli
查看>>
MySQLIntegrityConstraintViolationException异常处理
查看>>
mysqlreport分析工具详解
查看>>
MySQLSyntaxErrorException: Unknown error 1146和SQLSyntaxErrorException: Unknown error 1146
查看>>
Mysql_Postgresql中_geometry数据操作_st_astext_GeomFromEWKT函数_在java中转换geometry的16进制数据---PostgreSQL工作笔记007
查看>>
mysql_real_connect 参数注意
查看>>
mysql_secure_installation初始化数据库报Access denied
查看>>