cloud.tencent.com
为例。tomcat-9.0.56
为例。名称 | 说明 |
服务器的 IP 地址 | 服务器的 IP 地址,用于 PC 连接到服务器。 |
用户名 | 登录服务器的用户名。 |
密码 | 登录服务器的密码。 |
/usr/Tomcat-9.0.56/conf
。cloud.tencent.com
证书文件包到本地目录。
解压缩后,可获得相关类型的证书文件。其中包含 cloud.tencent.com_jks
文件夹:cloud.tencent.com_jks
cloud.tencent.com.jks
密钥库keystorePass.txt
密码文件(若已设置私钥密码,则无 keystorePass.txt
密码文件)cloud.tencent.com.jks
密钥库文件从本地目录拷贝至 Tomcat 配置文件目录 /usr/Tomcat-9.0.56/conf
。/usr/Tomcat-9.0.56/conf
目录下的 server.xml
文件。添加如下内容:<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"maxThreads="150" scheme="https" secure="true"#证书保存的路径keystoreFile="Tomcat 安装目录/conf/cloud.tencent.com.jks"#密钥库密码keystorePass="******"clientAuth="false"/>
server.xml
文件请参考如下内容:<?xml version="1.0" encoding="UTF-8"?><Server port="8005" shutdown="SHUTDOWN"><Listener className="org.apache.catalina.startup.VersionLoggerListener" /><Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /><Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /><Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /><Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /><GlobalNamingResources><Resource name="UserDatabase" auth="Container"type="org.apache.catalina.UserDatabase"description="User database that can be updated and saved"factory="org.apache.catalina.users.MemoryUserDatabaseFactory"pathname="conf/tomcat-users.xml" /></GlobalNamingResources><Service name="Catalina"><Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /><Connector port="443" protocol="HTTP/1.1"maxThreads="150" SSLEnabled="true" scheme="https" secure="true"clientAuth="false"keystoreFile="Tomcat 安装目录/conf/cloud.tencent.com.jks"keystorePass="******" /><Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /><Engine name="Catalina" defaultHost="cloud.tencent.com"><Realm className="org.apache.catalina.realm.LockOutRealm"><Realm className="org.apache.catalina.realm.UserDatabaseRealm"resourceName="UserDatabase"/></Realm><Host name="cloud.tencent.com" appBase="webapps"unpackWARs="true" autoDeploy="true" ><Context path="" docBase ="Knews" /><Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"prefix="localhost_access_log" suffix=".txt"pattern="%h %l %u %t "%r" %s %b" /></Host></Engine></Service></Server>
bin
目录下(例如:/usr/Tomcat-9.0.56/bin
)依次执行以下命令,关闭和重启 Tomcat 服务。./shutdown.sh (关闭 Tomcat 服务)./startup.sh (启动 Tomcat 服务)
bin
目录下(例如:/usr/Tomcat-9.0.56/bin
)执行以下命令,启动 Tomcat 服务。./startup.sh
https://cloud.tencent.com
进行访问。conf
目录下(例如:/usr/Tomcat-9.0.56/conf
)的 web.xml
文件,并找到 </welcome-file-list>
标签。<login-config><!-- Authorization setting for SSL --><auth-method>CLIENT-CERT</auth-method><realm-name>Client Cert Users-only Area</realm-name></login-config><security-constraint><!-- Authorization setting for SSL --><web-resource-collection><web-resource-name>SSL</web-resource-name><url-pattern>/*</url-pattern></web-resource-collection><user-data-constraint><transport-guarantee>CONFIDENTIAL</transport-guarantee></user-data-constraint></security-constraint>
conf
目录下(例如:/usr/Tomcat-9.0.56/conf
)的 server.xml
文件,将 redirectPort
参数修改为 SSL 的 connector 的端口,即443端口。如下所示:<Connector port="80" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="443" />
/bin
目录下(例如:/usr/Tomcat-9.0.56/bin
)执行以下命令,关闭 Tomcat 服务。./shutdown.sh
./configtest.sh
http://cloud.tencent.com
进行访问。./startup.sh
本页内容是否解决了您的问题?