CentOS 7配置tomcat https并改端口为443

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 7配置tomcat https并改端口为443相关的知识,希望对你有一定的参考价值。

CentOS 7配置tomcat https并改端口为443:

安装tomcat:

yum install tomcat (默认为tomcat 7)

配置tomcat证书(有公司https key、crt文件情况):

openssl pkcs12 -export -in ming.crt -inkey ming.key -out ming.p12 -certfile gd_bundle-g2-g1.crt

设置密码

keytool -importkeystore -alias 1 -destkeystore tomcat.keystore -srckeystore ming.p12 -srcstoretype pkcs12

设置同上密码

cp -rv tomcat.keystore /etc/tomcat/

修改端口为443

vi /etc/tomcat/server.xml (需改2处)

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />

<Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="/etc/tomcat/tomcat.keystore" keystorePass="xxxxx" />

:wq

安装authbind

rpm -i https://s3.amazonaws.com/aaronsilber/public/authbind-2.1.1-0.1.x86_64.rpm

touch /etc/authbind/byport/443

chown tomcat:tomcat /etc/authbind/byport/443

chmod 500 /etc/authbind/byport/443

vi /usr/lib/systemd/system/tomcat.service

#ExecStart=/usr/libexec/tomcat/server start
ExecStart=/usr/bin/authbind -deep "/usr/libexec/tomcat/server" start

:wq

重启tomcat:

systemctl daemon-reload

systemctl restart tomcat

验证:

netstat -nptl | grep 443

浏览器访问:https://ip

以上是关于CentOS 7配置tomcat https并改端口为443的主要内容,如果未能解决你的问题,请参考以下文章

CentOS-6.5安装配置Tomcat-7

怎么改tomcat的端口号?

在CentOS 7中安装与配置Tomcat-8.5方法

Linux(CentOS 7.4)下安装JDK(1.7)和tomcat(7.0)

Linux(CentOS 7.4)下安装JDK(1.7)和tomcat(7.0)

Linux------环境配置(CentOS 7) 安装JDK Tomcat Nginx MySQL