- 双端口在conf/server.xml里加两个Connector
<Connector port="8888" redirectPort="8443"
connectionTimeout="20000" disableUploadTimeout="true"
acceptCount="100" enableLookups="false"
maxSpareThreads="75" minSpareThreads="25"
maxThreads="150" maxHttpHeaderSize="8192" />
<Connector port="80" connectionTimeout="20000"
protocol="HTTP/1.1" maxThreads="150"
sslProtocol="TLS" clientAuth="false" keystorePass="密钥"
keystoreFile="证书路径" secure="true"
scheme="https" SSLEnabled="true" />
- conf/web.xml里在最后</welcome-file-list>标签后面,</web-app>标签里不加如下代码,http和https都可以访问。
<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>
</web-app>
web.xml若不加上述代码,则tomcat同时支持http和https访问;若加上代码,则http自动跳转https,即只支持https。
当http自动跳转https时,其他软件程序调用tomcat下的网页会连接超时,但是问题出在哪里还没找到,所以只能从tomcat方面做改动。
网友评论