1. 基础:
1.1. 描述:内网的tomcat接到外网nginx转发过来的请求之后需要和外网的客户端进行通讯,为了保证通讯内容的安装,使用tomcat使用https协议。
1.2. 链接:http://tomcat.apache.org/
2. 版本:
2.1 安装包版本:
apache-tomcat-8.5.6
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
jdk1.8
openssl:https://www.openssl.org/source/openssl-1.0.2k.tar.gz
2.2 服务器版本:
Linux发行版:Red Hat Enterprise Linux Server release 6.8 (Santiago)
内核版本: 2.6.32-642.el6.x86_64
3. 安装:
3.1. 操作系统安装:(略)
3.2. apr安装:(见http://www.cnblogs.com/demonzk/p/6401538.html)
3.3. Java安装:(略)
3.3. tomcat安装:(略)
3.5. tomcat-native安装:
3.5.1. 环境:
tomcat:/opt/lds/apache-tomcat-8.5.6
apr:/usr/local/apr
java:/usr/local/jdk1.8
gcc:
==> 如果不安装gcc会无法编译
openssl:要求版本1.0.2以上
==> 如果不安装openssl会出现
15-Feb-2017 15:55:59.927 SEVERE [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Failed to initialize the SSLEngine. org.apache.tomcat.jni.Error: 70023: This function has not been implemented on this platform
==>rhel6.8默认使用openssl1.0.1版本,编译tomcat-native会报错,需要安装1.0.2版本
3.5.2. 解压:
[root@cftjapi02 bin]# pwd
/opt/lds/apache-tomcat-8.5.6/bin
[root@cftjapi02 bin]# ll tomcat-native.tar.gz
-rw-r-----. 1 root root 391853 Oct 7 04:16 tomcat-native.tar.gz
[root@cftjapi02 bin]# tar xf tomcat-native.tar.gz
[root@cftjapi02 bin]# cd tomcat-native
3.5.3. 配置:找到native文件夹:
3.5.4. 编译与安装tomcat-native:
4. 配置tomcat
4.1. ssl证书生成:使用openssl生成证书,(略),我使用的是签证机构签好的证书。
4.2. 在tomcat目录下找到conf/server.conf,去掉下面这段的注释
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
certificateFile="conf/localhost-rsa-cert.pem"
certificateChainFile="conf/localhost-rsa-chain.pem"
type="RSA" />
</SSLHostConfig>
</Connector>
假设key文件都在conf下面,把上面的内容替换成
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/79c17f7276822007.crt"
certificateFile="conf/homecredit.key"
type="RSA" />
</SSLHostConfig>
</Connector>