2月16
(1) 配置自动跳转前,请先用https访问您的网站,确认网站正常显示。
(2) 编辑server.xml:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
蓝色部分8443修改为443,修改后:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
蓝色部分8443修改为443,修改后如图所示:
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
(3) 编辑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>
(4) 重启Tomcat服务,输入http://域名,观察是否自动跳转到https://域名。
(2) 编辑server.xml:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
蓝色部分8443修改为443,修改后:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
蓝色部分8443修改为443,修改后如图所示:
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
(3) 编辑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>
(4) 重启Tomcat服务,输入http://域名,观察是否自动跳转到https://域名。