tomcat配置自动跳转https

单向认证的配置
复制已正确导入认证回复的keystore.jks文件到Tomcat安装目录下的conf目录。

1,打开conf目录下的server.xml文件,找到以下内容:

<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->

修改为:

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

默认的SSL访问端口号为443,如果使用其他端口号,则您需要使用https://yourdomain:port的方式来访问您的站点。

 

2,找到并修改以下内容:

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

 

3,找到并修改以下内容:
<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443" />

 

4,在tomcat\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>

发表评论